aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/persistence.rb
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-08-24 10:21:58 -0400
committerNeeraj Singh <neerajdotname@gmail.com>2010-08-24 10:21:58 -0400
commitf460de1d237e02fdbc3006bc91813efe7837f576 (patch)
treef2674596d27f14b35e1384803ee2655692840a72 /activerecord/lib/active_record/persistence.rb
parent02aabbd19e59720d2d5819978d2f712c2279bf34 (diff)
downloadrails-f460de1d237e02fdbc3006bc91813efe7837f576.tar.gz
rails-f460de1d237e02fdbc3006bc91813efe7837f576.tar.bz2
rails-f460de1d237e02fdbc3006bc91813efe7837f576.zip
touch operationg if used along with belongs_to will also be invoked on associated objects
Diffstat (limited to 'activerecord/lib/active_record/persistence.rb')
-rw-r--r--activerecord/lib/active_record/persistence.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index 0188972169..c342824712 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -208,10 +208,14 @@ module ActiveRecord
# If an attribute name is passed, that attribute is updated along with
# updated_at/on attributes.
#
- # Examples:
- #
# product.touch # updates 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)
attributes = timestamp_attributes_for_update_in_model
attributes << name if name