Reusing named_scope to define another named_scope?

Refer to this question raised time ago here at SO. There is a patch at lighthouse to achieve your requirement.

You can use a method to combine some named_scope like : def self. From_big_guys self.class. User_group_managers_salary_greater_than(100) end This feature is add on Rails 3 with new syntax (m.onkey.org/2010/1/22/active-record-quer...).

Defining a class method is inconvenient because it's not a named_scope, so, for example, it can't be chained as such. – NomadCoder Mar 14 '10 at 21:24 Actually it can be -- just return a scope using where() or whatever: edgerails. Info/articles/what-s-new-in-edge-rails/2010/02/23/… – adzdavies Mar 29 at 1:20.

You can use proxy_options to recycle one named_scope into another: class Thing #... named_scope :billable_by, lambda{|user| {:conditions => {:billable_id => user. Id } } } named_scope :billable_by_tom, lambda{ self. Billable_by(User.

Find_by_name('Tom'). Id). Proxy_options } #... end This way it can be chained with other named_scopes.

I use this in my code and it works perfectly. I hope it helps.

Caveat is that proxy_options only returns the scope of the latest named scope, so this cannot be done against another derived named scope. – fullware Sep 8 '10 at 22:31.

One day, if I'm not mistaken, I have seen an example of reusing a named_scope to define another named_scope. The question is: what is the exact syntax, if it's possible at all? I can't find it back, and Google was of no help either.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions