Are Ducks Hibernating?

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.

Not important, but I’m curious why…

Seasons Greetings,

Am Mittwoch, den 21.12.2005, 09:49 +0100 schrieb Mathieu C.:

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs