I think your #search
method is probably returning something (an Array
?) that does not implement some method that named_scope
expects. From a quick look into activerecord/lib/active_record/named_scope.rb
it appears that named_scope
returns a Scope
object, which does implement #call
(and a bunch of other non-Array methods too). That looks to be why chaining scopes works. So an Array just isn't going to work.
Could you rework your #search
method into a named_scope
? I realise that you're going to get an unusually (for me, at least) complex definition, but you should then be able to chain your results with other scopes.
Alternatively, how about making your custom search method work so that it returns (and must also take, for chaining before and after to work) a Scope? Probably haarder to do than a big named_scope though.