Find() - can it be overridden?

Hi, is it possible to override Active Record find() in a class that
inherits Active Record?

eg.

def find
   super
   <blah blah>
end

I've tried it and it doesn't seem to work!

It can be overridden, but it depends on your requirement. Do you just
want to process a result_set returned from the super? Or do you want
to pass additional options to the super? Or do you want to rewrite it
completely?

It is a bit difficult say since the requirement is unclear.

Long

"Lee" wrote:

Find is a class method. Your example below creates an instance method called find. To override the AR find class method do something like this:

def ClassName.find(*args)
super(*args)
end

Hi Lee --

Actually, super's default behaviour is to slurp up all the args that came into the method in the first place, so the argument is superfluous. See this post for an example of overriding find to set a default order for a model.

http://groups.google.com/group/rubyonrails-talk/msg/5ef476cfdd0b3797

/Jeff