Co usar date_select


#1

Hello:

I have a problem with dateHelper date_select. I think this is a bug.

In a form, I’ve to list many objects of type “formacio” that a “persona”
have.

“formacio” object have an “id”, two foreing key “centre_id” and
“titulacio_id” and a “finalitza_on” date.

The form have to be used to update attributes of all “formacions” of a
“persona”.

In a form I have this code:

<% @persona.formacions.each do |@formacio| %>

<%= select("formacio[]","titulacio_id", @titulacions ,{:include_blank => true }) %> <%= select("formacio[]","centre_id", @centres ,{:include_blank => true }) %> <%= date_select("formacio[]", "finalitza_on" ) %>
<%= link_to "Borrar",{ :action => "borrar_formacio", :id => @persona, :f_id => @formacio } %> <% end %>

Whell, the indexation with [] go pretty well with “titulacio_id” and
“centre_id” but not with “finalitza_on”.

The params generated for two objects “formacio” with ids “25” and “26”
are:

Parameters: {“formacio”=>{
“finalitza_on(2i)”=>“3”,
“finalitza_on(3i)”=>“5”,
“25”=>{“centre_id”=>"", “titulacio_id”=>“2”},
“26”=>{“centre_id”=>"", “titulacio_id”=>“3”},
“finalitza_on(1i)”=>“1983”},
“commit”=>“Actualitza”,
“id”=>“9”
}

But what I need is:

Parameters: {“formacio”=>{
,
“25”=>{ “centre_id”=>"",
“titulacio_id”=>“2”,
“finalitza_on(2i)”=>“3”,
“finalitza_on(3i)”=>“5”,
“finalitza_on(1i)”=>“1983”
},
“26”=>{ “centre_id”=>"",
“titulacio_id”=>“3”
“finalitza_on(2i)”=>“6”,
“finalitza_on(3i)”=>“3”,
“finalitza_on(1i)”=>“1985”
},
“commit”=>“Actualitza”,
“id”=>“9”
}

More information about my system:

$ ruby -v
ruby 1.8.4 (2005-10-29) [i486-linux]

$ dpkg -l rails
++±===================-===================-============================
ii rails 0.14.3-1 MVC ruby based framework

I’m using mysql on a Debian GNU/linux

$ mysql -V
mysql Ver 14.7 Distrib 4.1.15, for pc-linux-gnu (i486) using readline
5.0

What’s going wrong?