Find() - can it be overridden?

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


def find
   <blah blah>

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

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


"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)

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.