You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that this happens only when using Rails fixtures.
As a quick workaround I added a monkey patch in my initializer:
# config/initializers/tod.rbifRails.env.test?# Fix for Rails fixtures storing a datetime in time fields.# The time value is prepended with the date "2000-01-01".moduleTodclassTimeOfDayclass << selfold_try_parse=instance_method(:try_parse)define_method(:try_parse)do |tod_string|
tod_string=tod_string.to_stod_string=tod_string[11..]iftod_string.starts_with?"2000-01-01 "old_try_parse.bind(self).(tod_string)endendendendend
I wonder if there's a better way to do that.
The text was updated successfully, but these errors were encountered:
I have a model with a
time
field like this:Then in my fixture I set the value like this:
But when I load the model the field is not set:
Digging a bit deeper I have found that the actual value in the database is this:
Note that this happens only when using Rails fixtures.
As a quick workaround I added a monkey patch in my initializer:
I wonder if there's a better way to do that.
The text was updated successfully, but these errors were encountered: