This project is archived and is in readonly mode.
[PATCH] time_select ..., :include_blank => true
Reported by Nolan Eakins | April 8th, 2009 @ 05:08 PM | in 3.x
I'm running into issues with time_select
raising
MultiparameterAssignmentErrors. It's very similar to the email
quoted below (http://markmail.org/message/lkzm...)
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:
00 01 02 03 21 22 23 : 00 15 30 45
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.
Comments and changes to this ticket
-
Nolan Eakins April 8th, 2009 @ 06:55 PM
- Title changed from time_select ..., :include_blank => true to [PATCH] time_select ..., :include_blank => true
Here's a patch that adds a couple test cases and a fix for this problem. It's also available at http://github.com/sneakin/rails
-
Nolan Eakins April 8th, 2009 @ 07:45 PM
Here's a better approach than the above. It changes ActiveRecord::Base to add the date when it does a multiparameter assignment with only the hour and minute. The above is flawed when you select a blank hour and blank minute. The [Date]Time would still be created causing 0:00 to get selected.
-
Daniel Tsadok July 13th, 2009 @ 09:03 PM
I'm having the same problem with time_select, :prompt => true
-
Daniel Tsadok July 13th, 2009 @ 10:04 PM
So I'm using the twelve-hour-plugin so that's probably what's doing it.
-
Aditya Sanghi October 17th, 2010 @ 07:40 PM
- State changed from new to duplicate
- Importance changed from to
Please see ticket 4346 where we're still discussing this issue after 2 years. We've provided a patch with many more tests and comprehensively covers date/time/datetime issues as well as positional parameters among other issues.
Marking this as duplicate. Please provide your comments and review on #4346.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>