Displaying 1 result from an estimated 1 matches for "dynamic_conditions_from_hash".
2006 Apr 13
2
Dynamic finder conditions
...ranges but
I''m embarrassed of it so I won''t show it here). Is there already something
like this out there? Also, is there any way I can make my code more
Ruby-fied?
Here''s what I have so far:
--application.rb
private
#this could probably stand to be renamed
def dynamic_conditions_from_hash(some_hash, model)
model = Class.new(model)
some_hash.delete_if { |key, value| not
model.column_names.include? key }
conditions_from_hash(some_hash)
end
def conditions_from_hash(some_hash)
condition = ''''
some_hash.each_pair {|key, value|
if value.empty?...