Skip to content

Commit

Permalink
touch operationg if used along with belongs_to will also be invoked o…
Browse files Browse the repository at this point in the history
…n associated objects
  • Loading branch information
Neeraj Singh authored and fxn committed Aug 24, 2010
1 parent 174d5cd commit 78f6f0d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions activerecord/lib/active_record/persistence.rb
Expand Up @@ -208,10 +208,14 @@ def reload(options = nil)
# If an attribute name is passed, that attribute is updated along with # If an attribute name is passed, that attribute is updated along with
# updated_at/on attributes. # updated_at/on attributes.
# #
# Examples:
#
# product.touch # updates updated_at/on # product.touch # updates updated_at/on
# product.touch(:designed_at) # updates the designed_at attribute and updated_at/on # product.touch(:designed_at) # updates the designed_at attribute and updated_at/on
#
# If used along with +belongs_to+ then +touch+ will invoke +touch+ method on associated object.
#
# Brake.belongs_to :car, :touch => true
# Car.belongs_to :corporation, :touch => true
# @brake.touch #=> will also invoke @brake.car.touch and @brake.car.corporation.touch
def touch(name = nil) def touch(name = nil)
attributes = timestamp_attributes_for_update_in_model attributes = timestamp_attributes_for_update_in_model
unless attributes.blank? unless attributes.blank?
Expand Down

0 comments on commit 78f6f0d

Please sign in to comment.