From 3edccfb08dfbb8f057682e41d9a75e877f7bd412 Mon Sep 17 00:00:00 2001 From: wangjohn Date: Mon, 25 Feb 2013 01:07:19 -0500 Subject: Added documentation about how touch now throws an error when one tries to use it on an unpersisted object. --- activerecord/lib/active_record/persistence.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activerecord/lib/active_record/persistence.rb') diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index 26c11b50a2..3f98d8f217 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -367,6 +367,13 @@ module ActiveRecord # # # 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? -- cgit v1.2.3