Active record taking Date.today as yesterday
Posted
by Mongus Pong
on Stack Overflow
See other posts from Stack Overflow
or by Mongus Pong
Published on 2010-05-23T02:16:22Z
Indexed on
2010/05/23
2:20 UTC
Read the original article
Hit count: 276
ruby-on-rails
|activerecord
I have a strange one..
I am doing something like :
tip = find (:first, :conditions => ["last_shown = ? or last_shown is null", Date.today])
And then a little later on I do :
tip.last_shown = Date.today
tip.save
When I look at output of these queries, ActiveRecord is doing the first query with todays date as I would expect.
However, the send query, ActiveRecord is setting the last_shown date to be yesterdays date.
Why on earth would it do this?
I have
config.time_zone = 'UTC'
in my environment.rb. I can use Time.now.utc.to_date instead of Date.today but it makes no difference.
© Stack Overflow or respective owner