diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/timestamp.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/timestamp.rb b/activerecord/lib/active_record/timestamp.rb index c3de93d552..eb82728a0e 100644 --- a/activerecord/lib/active_record/timestamp.rb +++ b/activerecord/lib/active_record/timestamp.rb @@ -19,21 +19,23 @@ module ActiveRecord end def create_with_timestamps #:nodoc: + if record_timestamps t = ( self.class.default_timezone == :utc ? Time.now.utc : Time.now ) - write_attribute("created_at", t) if record_timestamps && respond_to?(:created_at) && created_at.nil? - write_attribute("created_on", t) if record_timestamps && respond_to?(:created_on) && created_on.nil? - - write_attribute("updated_at", t) if record_timestamps && respond_to?(:updated_at) - write_attribute("updated_on", t) if record_timestamps && respond_to?(:updated_on) + write_attribute('created_at', t) if respond_to?(:created_at) && created_at.nil? + write_attribute('created_on', t) if respond_to?(:created_on) && created_on.nil? + write_attribute('updated_at', t) if respond_to?(:updated_at) + write_attribute('updated_on', t) if respond_to?(:updated_on) + end create_without_timestamps end def update_with_timestamps #:nodoc: + if record_timestamps t = ( self.class.default_timezone == :utc ? Time.now.utc : Time.now ) - write_attribute("updated_at", t) if record_timestamps && respond_to?(:updated_at) - write_attribute("updated_on", t) if record_timestamps && respond_to?(:updated_on) - + write_attribute('updated_at', t) if respond_to?(:updated_at) + write_attribute('updated_on', t) if respond_to?(:updated_on) + end update_without_timestamps end end |