File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
activerecord/lib/active_record Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -479,7 +479,12 @@ def reload(options = nil)
479479 # ball.touch(:updated_at) # => raises ActiveRecordError
480480 #
481481 def touch ( *names , time : nil )
482- raise ActiveRecordError , "cannot touch on a new record object" unless persisted?
482+ unless persisted?
483+ raise ActiveRecordError , <<-MSG . squish
484+ cannot touch on a new or destroyed record object. Consider using
485+ persisted?, new_record?, or destroyed? before touching
486+ MSG
487+ end
483488
484489 time ||= current_time_from_proper_timezone
485490 attributes = timestamp_attributes_for_update_in_model
Original file line number Diff line number Diff line change @@ -8,7 +8,12 @@ module TouchLater
88 end
99
1010 def touch_later ( *names ) # :nodoc:
11- raise ActiveRecordError , "cannot touch on a new record object" unless persisted?
11+ unless persisted?
12+ raise ActiveRecordError , <<-MSG . squish
13+ cannot touch on a new or destroyed record object. Consider using
14+ persisted?, new_record?, or destroyed? before touching
15+ MSG
16+ end
1217
1318 @_defer_touch_attrs ||= timestamp_attributes_for_update_in_model
1419 @_defer_touch_attrs |= names
You can’t perform that action at this time.
0 commit comments