Extending find() in a horrible way

Hi all,

I’m trying to add a default scope to all calls to find.

My method is really ugly and wondered if anyone had a better solution?
It also doesn’t effect all the dynamic finder methods.

(I’ve posted this a couple of times but I’m not seeing it in google
groups… not sure if this will work.)

cheers
-h

class LinkCategory < ActiveRecord::Base

def self.find(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
sql = “site_id=’#{some_integer}’”
if options[:conditions] && !options[:conditions].empty?
options[:conditions] += " AND #{sql}"
else
options[:conditions] = “#{sql}”
end
args << options
super(*args)
end

end

honestly I have no dang idea what thats suppose to do how about some
documentation?

Try this:

http://roman2k.free.fr/rails/meantime_filter/0.1.2/

it is exactly what you need.

pt.

On 11/13/06, Henry T. [email protected] wrote:

else
options[:conditions] = “#{sql}”
end
args << options
super(*args)
end

end


Parker T.

510.541.0125

Wow, thanks for the link… My favourite plugin so far…

cheers
-henry