Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #9409 from wangjohn/adding_documentation_to_touch

Added documentation to touch throwing an error
  • Loading branch information...
commit 82c361e1462d714a076e0033398c393d0048d649 2 parents d5141f2 + 3edccfb
Carlos Antonio da Silva carlosantoniodasilva authored
Showing with 7 additions and 0 deletions.
  1. +7 −0 activerecord/lib/active_record/persistence.rb
7 activerecord/lib/active_record/persistence.rb
View
@@ -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?
Please sign in to comment.
Something went wrong with that request. Please try again.