mirror of
https://github.com/github/rails.git
synced 2026-01-24 13:58:12 -05:00
Speed up timestamping a tad #1227 [skaen]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1327 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user