for some reason though, No is selected initially when no GET parameter
is passed and the options are not in the correct order. they show up
like the following:
for some reason though, No is selected initially when no GET parameter
is passed and the options are not in the correct order. they show up
like the following:
Hashes are not ordered in ruby 1.8 - if you want an ordering use an
array (eg [['Yes', 1], ['No',0]]).
For an option to be preselected it's value (the second bit) must be
equal to the last argument to select_tag (equal in the sense of ==, so
in particular '1' != 1)
In your case you are passing params[:fake].to_i. If there are no
parameters then params[:fake] is nil, and nil.to_i == 0 so rails
selects the option with value 0.