diff options
author | Geoff Buesing <gbuesing@gmail.com> | 2009-08-03 21:54:40 -0500 |
---|---|---|
committer | Geoff Buesing <gbuesing@gmail.com> | 2009-08-03 22:03:47 -0500 |
commit | 6f97ad07ded847f29159baf71050c63f04282170 (patch) | |
tree | 7b02c02470f32eeb4c6e3c91008d74e6d093c445 /activerecord/lib/active_record | |
parent | 9b68877897a44d4484cde40117abc42c9b029154 (diff) | |
download | rails-6f97ad07ded847f29159baf71050c63f04282170.tar.gz rails-6f97ad07ded847f29159baf71050c63f04282170.tar.bz2 rails-6f97ad07ded847f29159baf71050c63f04282170.zip |
quoted_date converts time-like objects to ActiveRecord::Base.default_timezone before serialization. This allows you to use Time.now in find conditions and have it correctly be serialized as the current time in UTC when default_timezone == :utc [#2946 state:resolved]
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/quoting.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb index 720fba29e9..8649f96498 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb @@ -60,7 +60,12 @@ module ActiveRecord end def quoted_date(value) - value.to_s(:db) + if value.acts_like?(:time) + zone_conversion_method = ActiveRecord::Base.default_timezone == :utc ? :getutc : :getlocal + value.respond_to?(zone_conversion_method) ? value.send(zone_conversion_method) : value + else + value + end.to_s(:db) end def quoted_string_prefix |