Permalink
Browse files

Added documentation about how touch now throws an error when one tries

to use it on an unpersisted object.
  • Loading branch information...
1 parent 3285c76 commit 3edccfb08dfbb8f057682e41d9a75e877f7bd412 @wangjohn wangjohn committed Feb 25, 2013
Showing with 7 additions and 0 deletions.
  1. +7 −0 activerecord/lib/active_record/persistence.rb
@@ -367,6 +367,13 @@ def reload(options = nil)
#
# # triggers @brake.car.touch and @brake.car.corporation.touch
# @brake.touch
+ #
+ # Note that +touch+ must be used on a persisted object, or else an
+ # ActiveRecordError will be thrown. For example:
+ #
+ # ball = Ball.new
+ # ball.touch(:updated_at) # => raises ActiveRecordError
+ #
def touch(name = nil)
raise ActiveRecordError, "can not touch on a new record object" unless persisted?

0 comments on commit 3edccfb

Please sign in to comment.