Am Mittwoch, den 21.12.2005, 09:49 +0100 schrieb Mathieu
Chappuis:> Dears,
>
> Remembering last value in a select box don''t work for me as :
>
> Controller :
> @years=(1970..2005).to_a
>
> Form:
> <%= select_tag "year", options_for_select( (2001..2005).to_a,
> @params[:year] ) %>
>
> I had to write
>
> <%= select_tag "year", options_for_select( (2001..2005).to_a,
> @params[:year].to_i ) %>
>
> for it works.
The Array items are compared to the selected value using the
''==''
comparator. You are comparing Integer == String, what result in false.
> Not important, but I''m curious why..
>
> Seasons Greetings,
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>