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)
479
479
# ball.touch(:updated_at) # => raises ActiveRecordError
480
480
#
481
481
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
483
488
484
489
time ||= current_time_from_proper_timezone
485
490
attributes = timestamp_attributes_for_update_in_model
Original file line number Diff line number Diff line change @@ -8,7 +8,12 @@ module TouchLater
8
8
end
9
9
10
10
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
12
17
13
18
@_defer_touch_attrs ||= timestamp_attributes_for_update_in_model
14
19
@_defer_touch_attrs |= names
You can’t perform that action at this time.
0 commit comments