From c8b4cf65df48b7340dc8337cb23186c5e263bb2b Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 19 May 2005 19:05:12 +0000 Subject: Speed up timestamping a tad #1227 [skaen] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1327 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/timestamp.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'activerecord/lib/active_record') 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 -- cgit v1.2.3