Browse files

Improve touch docs with extra attributes passed in [ci skip]

  • Loading branch information...
1 parent 140ea22 commit bebe4a9ddde078c091e48ab06c4ca4c8da37203f @carlosantoniodasilva carlosantoniodasilva committed Mar 20, 2014
Showing with 10 additions and 11 deletions.
  1. +3 −6 activerecord/CHANGELOG.md
  2. +7 −5 activerecord/lib/active_record/persistence.rb
View
9 activerecord/CHANGELOG.md
@@ -1,12 +1,9 @@
-* `ActiveRecord#touch` should accept many attributes at once. Suggested at #14423.
+* `touch` accepts many attributes to be touched at once.
Example:
- photo = Photo.last
- photo.touch(:signed_at, :sealed_at)
- photo.updated_at # was changed
- photo.signed_at # was changed
- photo.sealed_at # was changed
+ # touches :signed_at, :sealed_at, and :updated_at/on attributes.
+ Photo.last.touch(:signed_at, :sealed_at)
*James Pinto*
View
12 activerecord/lib/active_record/persistence.rb
@@ -407,14 +407,16 @@ def reload(options = nil)
# Saves the record with the updated_at/on attributes set to the current time.
# Please note that no validation is performed and only the +after_touch+,
# +after_commit+ and +after_rollback+ callbacks are executed.
- # If an attribute name is passed, that attribute is updated along with
- # updated_at/on attributes.
#
- # product.touch # updates updated_at/on
- # product.touch(:designed_at) # updates the designed_at attribute and updated_at/on
+ # If attribute names are passed, they are updated along with updated_at/on
+ # attributes.
+ #
+ # 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.
+ # If used along with +belongs_to+ then +touch+ will invoke +touch+ method on
+ # associated object.
#
# class Brake < ActiveRecord::Base
# belongs_to :car, touch: true

0 comments on commit bebe4a9

Please sign in to comment.