On Mar 1, 2008, at 8:25 PM, dino d. wrote:
>
> Hi - I want to define a customized finding method on a class, that is
> accessible to the class, not just the object, just like you can say
> Class.find(:all) for ActiveRecord without needing an instance of
> Class.
>
> So, I might want to do something like:
>
> def specials
> find(... these would be the find parameters) #does this call
> Class.find?
> end
>
> def popular
> find(... again, particular find params)
> end
>
> I tried this, but I cannot call the methods from the class, it looks
> like I need an object. Is there a particular way to declare a class-
> level function? If not, does Ruby just assume the programmer is not
> doing any object-specific work?
>
> Thanks,
> Dino
class Movie
def self.popular(options = {})
Movie.find(:all, options.merge({:conditions = "review_count >
100"}))
end
end
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---