diff options
author | Richard Schneeman <richard.schneeman@gmail.com> | 2016-07-03 10:35:31 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-03 10:35:31 -0500 |
commit | ee50de03908f24c377d4842f759182fe9241c6fa (patch) | |
tree | 9d191096e2aa6c0945f2365fd46835660a846950 /activerecord/lib/active_record/touch_later.rb | |
parent | d3c444fb3b450f3a11c244017e92850ff3d9f62f (diff) | |
parent | ac156060a4dd81ea1f7730affb1491ceb3c973d0 (diff) | |
download | rails-ee50de03908f24c377d4842f759182fe9241c6fa.tar.gz rails-ee50de03908f24c377d4842f759182fe9241c6fa.tar.bz2 rails-ee50de03908f24c377d4842f759182fe9241c6fa.zip |
Merge pull request #25241 from aguynamedben/fix-touch-error-messages
Improve error message when record touch fails.
Diffstat (limited to 'activerecord/lib/active_record/touch_later.rb')
-rw-r--r-- | activerecord/lib/active_record/touch_later.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/touch_later.rb b/activerecord/lib/active_record/touch_later.rb index 9a80a63e28..5c41ab6e39 100644 --- a/activerecord/lib/active_record/touch_later.rb +++ b/activerecord/lib/active_record/touch_later.rb @@ -8,7 +8,12 @@ module ActiveRecord end def touch_later(*names) # :nodoc: - raise ActiveRecordError, "cannot touch on a new record object" unless persisted? + unless persisted? + raise ActiveRecordError, <<-end_error.strip_heredoc + cannot touch on a new or destroyed record object. Consider using + persisted?, new_record?, or destroyed? before touching + end_error + end @_defer_touch_attrs ||= timestamp_attributes_for_update_in_model @_defer_touch_attrs |= names |