diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-05-19 19:05:12 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-05-19 19:05:12 +0000 |
commit | c8b4cf65df48b7340dc8337cb23186c5e263bb2b (patch) | |
tree | 785478ee7eb76a6a3f2532e01ea9301c2892bec8 /activerecord | |
parent | 977671c226c205c0d26e9bca65cacf05b71d545f (diff) | |
download | rails-c8b4cf65df48b7340dc8337cb23186c5e263bb2b.tar.gz rails-c8b4cf65df48b7340dc8337cb23186c5e263bb2b.tar.bz2 rails-c8b4cf65df48b7340dc8337cb23186c5e263bb2b.zip |
Speed up timestamping a tad #1227 [skaen]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1327 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
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 |