Hi all,
I'm trying to extend ActiveRecord::Base.find() to include a default scope with every query... I've pasted my dirty attempt below. Surely theres a better way?
Another problem with the below is that all the dynamic finder methods aren't effected.
Any ideas?
cheers -henry
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