aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/timestamp.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-08-14 12:43:57 -0600
committerSean Griffin <sean@thoughtbot.com>2014-08-15 05:56:45 -0600
commita3ee03083b50e1458c1276f499226ec59c0fb73d (patch)
tree0bb2411e5de001253875b71599fefec53870ee31 /activerecord/lib/active_record/timestamp.rb
parent4751a8c51ff4b9766dcf8324347477095b7f940d (diff)
downloadrails-a3ee03083b50e1458c1276f499226ec59c0fb73d.tar.gz
rails-a3ee03083b50e1458c1276f499226ec59c0fb73d.tar.bz2
rails-a3ee03083b50e1458c1276f499226ec59c0fb73d.zip
Use the method for determining attribute methods rather than duplicating
I've been trying to reduce the number of places that care about `attributes`, and its existence. We have a method for this check, let's use it instead.
Diffstat (limited to 'activerecord/lib/active_record/timestamp.rb')
-rw-r--r--activerecord/lib/active_record/timestamp.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/timestamp.rb b/activerecord/lib/active_record/timestamp.rb
index 5ef98ed820..417cd61f0c 100644
--- a/activerecord/lib/active_record/timestamp.rb
+++ b/activerecord/lib/active_record/timestamp.rb
@@ -47,8 +47,9 @@ module ActiveRecord
current_time = current_time_from_proper_timezone
all_timestamp_attributes.each do |column|
- if attributes.key?(column.to_s) && self.send(column).nil?
- write_attribute(column.to_s, current_time)
+ column = column.to_s
+ if has_attribute?(column) && !attribute_present?(column)
+ write_attribute(column, current_time)
end
end
end