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

Try this:

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

it is exactly what you need.

pt.

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

cheers
-henry