diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-08-14 12:43:57 -0600 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-08-15 05:56:45 -0600 |
commit | a3ee03083b50e1458c1276f499226ec59c0fb73d (patch) | |
tree | 0bb2411e5de001253875b71599fefec53870ee31 /activerecord/lib/active_record/timestamp.rb | |
parent | 4751a8c51ff4b9766dcf8324347477095b7f940d (diff) | |
download | rails-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.rb | 5 |
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 |