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