[Rails] Re: Named scope in named scope ??
On Sep 23, 9:29 pm, Adrien Coquio <adrien.coq...@gmail.com> wrote:
> Hi,
>
> I would like to return a combination of named scopes in a named
> scope :
>
> For example, I have a named scope filter and I want to add a named
> scope eval_filters like
>
> Product.eval_filters(['x','y','z']) is equivalent to
> Product.filter('x').filter('y').filter('z')
>
Well it wouldn't be a scope strictly speaking, but it would return a
scope and I believe you could call it on a scope:
def self.eval_filters(filters)
filters.inject(self) { |scope, filter| scope.send filter}
end
> Anybody know how can I define the named_scope eval_filters to do
> that ?
>
> Thanks
>
> adrien :)
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home