I’m going nuts over this incidence in my code: I have this class
AdsSources < ActiveRecord::Base and one of it’s fields is a date, but
when I update this field and read it again, I always get the same
wrong date like this:
I don’t get any Exceptions from this operation and it doesn’t matter
if I use a different method like update_attributes, the result will be
the same. Now, and this can be as soon as the following line in my
code, I read this value like this:
@a.last_time_polled
And no matter when or how I updated this field the last time, I always
get the same date:
Sat Jan 01 22:43:26 +0100 2000
January 1st 2000. Could someone point me a reason for this? Thanks.
Use a :datetime field type instead of plain :date. I’m supposing thats
the data type you have in your migration.
Or if the date is not important, you can go with a pure :time
approach.
Thanks for your replies, guys.
I checked the content in the database and found that only the time of
the day was being stored, so I changed the type of the column to
‘timestamp’ and it’s working properly now.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.