I have a couple of time field (MySQL data type: time) "start_time" and
"end_time", and I'm trying to use a time_select helper to save the
data. Here's how I'm using it:
Update - I just noticed that it will save a new record without this
error if I have the minutes other than "00". But there still is an
issue, since it saves the parameters as Year and Month instead of Hour
and Minute! So this is interpreted as
and
@activity.activity_start_time = Time.parse("00:00")
@activity.activity_end_time = Time.parse("00:00")
inside the controller, so that the current time won't be selected by
default for new records. Kind of annoying that I can't have prompt or
blank at the top. :-\ If anyone has figured out a way to make
time_select work as expected, I'm all ears!
So for multiparameter attribute assignment, it just sorts the index
number alphabetically and uses the data fields to assign to the
object, in order (at least for Time / DateTime objects and likely for
Date objects as well). It then appears to begin assigning the data to
the fields, starting with the "first" field (year) and moving on,
ignoring the actual numeric value of the "index" (such as my 100 above
which results in its value becoming the month). So, with the rails
helper defaults of '4i' and '5i', the 5 becomes the 'month' and '00'
is an invalid month number.
So, this would appear to be a weakness/bug in rails from my
perspective. I'd think it should actually strip off the data-type
character (the 'i' chars in this case) and cast the remaining 'index'
characters to a Fixnum (again, at least for date/time types, not sure
about aggregates/others) at which point it should respect the number
as an offset: 1 => year, 2 => month, and so on so that this usage, as
written out by the view helper, actually works as expected.
Anyhow, just my two cents.
To work around, I'd drop the :ignore_date options in your helpers.
Then manually overwrite the YYYY-MM-DD value(s) of these two fields to
a consistent default (since I'm assuming you're not using the date
part anyway) so you can compare time values.
Thanks for confirming what I was experiencing! (At least I know I'm
not seeing things...)
I've never submitted a bug report for ror - is this the right place?
https://rails.lighthouseapp.com/dashboard