Hello everyone,
I'm having issues with a "time" field in a model. On the view, I use a time_select helper to generate the select for this field, and since I need this field to be NULL sometimes, I include the option :include_blank => true, like this:
<%= time_select 'support', 'duration', :minute_step => 15, :include_blank => true %>
The problem is that when I use :include_blank, the generated select comes with the hidden fields (of year, month and day) empty, like this:
<input name='support[duration(1i)]' type='hidden' id='support_duration_1i' value='' /> <input name='support[duration(2i)]' type='hidden' id='support_duration_2i' value='' /> <input name='support[duration(3i)]' type='hidden' id='support_duration_3i' value='' /> <select name='support[duration(4i)]' id='support_duration_4i'> <option value=''></option> <option value='00'>00</option> <option value='01'>01</option> <option value='02'>02</option> <option value='03'>03</option> ... <option value='21'>21</option> <option value='22'>22</option> <option value='23'>23</option> </select> : <select name='support[duration(5i)]' id='support_duration_5i'> <option value=''></option> <option value='00'>00</option> <option value='15'>15</option> <option value='30'>30</option> <option value='45'>45</option> </select>
And so, when I submit the form with the time field filled, I get an ActiveRecord::MultiparameterAssignmentErrors. If I don't set the option :include_blank => true, the hidden fields for year, month and day come filled with the respective current values, which are ignored by MySQL since we're storing them in a time field, not a datetime, and the insert or update goes on fine.
Is this a Rails bug (i'm using version 1.2.2) or am I doing something wrong here?
Thanks, Rodrigo.