"George писал(а): "
Maybe I should ask this in Ruby forum. Can anybody tell me how to create a hash before invoke the 'find' method and use this hash as parameter for the method?
Smt like:
find_hash = Hash.new if condition1 find_hash[ :all ] = true ??? else find_hash[ :first ] = true ??? end
....
users.find( find_hash )
thank
-- Posted via http://www.ruby-forum.com/.
find() accepts options hash as a second optional parameter. :first or :all symbol is a method parameter, not a hash value. What you need is: find_params = if condition1 find_params[0] = :all else find_params[0] = :first end
all other options, such as limit, group or include should be placed in the options hash, e.g. find_params[1] = {:include => :posts, :limit => 10}
then the find method is called in this way: users.find(*find_params)