Created
March 19, 2009 22:07
-
-
Save Odaeus/82092 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conds = {:name => params[:name], :cas_number => params[:cas_number]}.reject {|k,v| v.nil? } | |
conds = conds.inject([[]]) {|h,(k,v)| h.first << "#{k} LIKE ?"; h << "%#{v}%"; h } | |
conds[0] = conds[0].join(' AND ') | |
ingredients = Ingredient.find(:all, :conditions => conds) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment