The essence of the problem, as I see it
Once, if I'm not mistaken, I saw an example of reusing named_scope to define another named_scope. Something like this (I don't remember the exact syntax, but this is exactly my question):
named_scope :billable, :conditions => ... named_scope :billable_by_tom, :conditions => { :billable => true, :user => User.find_by_name('Tom') }
Question: what kind of syntax, if at all possible? I canโt find it back, and Google didnโt help either.
Some explanation
Why I really want this, I use Searchlogic to define a complex search that can lead to an expression like this:
Card.user_group_managers_salary_greater_than(100)
But it's too long to be everywhere. Since, as far as I know, Searchlogic simply defines named_scopes on the fly, I would like to set named_scope in the Card class as follows:
named_scope from_big_guys, { user_group_managers_salary_greater_than(100) }
- this is where I will use this long Searchlogic method inside my named_scope. But, again, what will be the syntax? Can not understand.
Summary
So, actually embedding scope_name is possible (and I don't mean the chain)?
ruby-on-rails activerecord
mxgrn
source share