Extend the find-method: more conditions


#1

Hi,

I want to share some helpful code snippet. Can it further be optimized?
Or is this even good to do?

Put this in your model to write a customized find method having more
conditions:

def self.find_active(*args)
options = extract_options_from_args!(args)
conditions = “AND (#{sanitize_sql(options[:conditions])})” if
options[:conditions]
options[:conditions] = “ADDITIONAL_CONDITIONS_GO_HERE
#{conditions}”
args << options
find(*args)
end

regards,
Helmut