aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2014-03-20 08:00:28 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2014-03-20 08:00:28 -0300
commit140ea2251b17ee9851e2511bf0a82a9e62197cd7 (patch)
tree9c45fec539f9b820e224c8c25f26153fff387288 /activerecord/lib/active_record
parenteafec4694c5b37eff9d83b1188b8e331fa6027fa (diff)
parentc80ca4c7803b4e8ed7f125ada9acc6b7c499af5f (diff)
downloadrails-140ea2251b17ee9851e2511bf0a82a9e62197cd7.tar.gz
rails-140ea2251b17ee9851e2511bf0a82a9e62197cd7.tar.bz2
rails-140ea2251b17ee9851e2511bf0a82a9e62197cd7.zip
Merge pull request #14423 from yakko/persistence-touches-many
ActiveRecord#touch should accept multiple attributes Conflicts: activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/persistence.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index d85fad1e13..eb45289b2e 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -412,6 +412,7 @@ module ActiveRecord
#
# product.touch # updates updated_at/on
# product.touch(:designed_at) # updates the designed_at attribute and updated_at/on
+ # product.touch(:started_at, :ended_at) # updates started_at, ended_at and updated_at/on attributes
#
# If used along with +belongs_to+ then +touch+ will invoke +touch+ method on associated object.
#
@@ -432,11 +433,11 @@ module ActiveRecord
# ball = Ball.new
# ball.touch(:updated_at) # => raises ActiveRecordError
#
- def touch(name = nil)
+ def touch(*names)
raise ActiveRecordError, "cannot touch on a new record object" unless persisted?
attributes = timestamp_attributes_for_update_in_model
- attributes << name if name
+ attributes.concat(names)
unless attributes.empty?
current_time = current_time_from_proper_timezone