# Class function vs. object function

**URL:** <https://www.ruby-forum.com/t/class-function-vs-object-function/130702>\
**Category:** Rails\
**Created:** [March 2, 2008, 5:26am UTC](https://www.ruby-forum.com/t/class-function-vs-object-function/130702 "2008-03-02T05:26:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dino\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@dino\_d](https://www.ruby-forum.com/u/dino_d)\
**Post date:** [March 2, 2008, 5:26am UTC](https://www.ruby-forum.com/t/class-function-vs-object-function/130702/1 "2008-03-02T05:26:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dino\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@dino\_d](https://www.ruby-forum.com/u/dino_d)\
**Post date:** [March 2, 2008, 6:34am UTC](https://www.ruby-forum.com/t/class-function-vs-object-function/130702/2 "2008-03-02T06:34:06Z")

</div>

On Mar 1, 2008, at 8:25 PM, dino d. wrote:

> Class.find?
> 
> Thanks,  
> Dino

class Movie  
def self.popular(options = {})  
Movie.find(:all, options.merge({:conditions = “review\_count \>  
100”}))  
end  
end
