ruby on rails - Named Scope Extensions - Calling Method Outside Do Block -
i have following named_scope in user model:
named_scope :all_stars, :joins => [:all_stars] def overall self.find(:all, :conditions => ['recordable_type = ?', 'user']) end end i want this:
named_scope :all_stars, :joins => [:all_stars] def overall overall_all_stars_condition end end def overall_all_stars_condition self.find(:all, :conditions => ['recordable_type = ?', 'user']) end can done?
if can make other thing named scope, can chain 2 scopes, want.
named_scope :all_stars, :joins => [:all_stars] named_scope :overall, :conditions => ['recordable_type = ?', 'user'] then should able call such:
object.all_stars.overall.all object.overall.all_stars.find(:all) # etc and create method same thing:
def overall_all_stars_condition self.all_stars.overall.all end
Comments
Post a Comment