aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/persistence.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-01-15 04:30:37 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-01-15 04:52:01 +0900
commit562dd0494a90d9d47849f052e8913f0050f3e494 (patch)
tree786aa2778e1ba384669b7100e24e16f4af1fa4a9 /activerecord/lib/active_record/persistence.rb
parentf1af27fd9d9101684b26d0dcf2028859d67bec1f (diff)
downloadrails-562dd0494a90d9d47849f052e8913f0050f3e494.tar.gz
rails-562dd0494a90d9d47849f052e8913f0050f3e494.tar.bz2
rails-562dd0494a90d9d47849f052e8913f0050f3e494.zip
Don't allow destroyed object mutation after `save` or `save!` is called
Currently `object.save` will unfreeze the object, due to `changes_applied` replaces frozen `@attributes` to new `@attributes`. Since originally destroyed objects are not allowed to be mutated, `save` and `save!` should not return success in that case. Fixes #28563.
Diffstat (limited to 'activerecord/lib/active_record/persistence.rb')
-rw-r--r--activerecord/lib/active_record/persistence.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index 462e5e7aaf..c1b1a5334a 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -694,6 +694,7 @@ module ActiveRecord
def create_or_update(*args, &block)
_raise_readonly_record_error if readonly?
+ return false if destroyed?
result = new_record? ? _create_record(&block) : _update_record(*args, &block)
result != false
end