diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-02-20 15:01:28 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-02-20 15:01:28 -0200 |
commit | 0f2261f2d10afade350378779104cdf0fc09605c (patch) | |
tree | e81d98c2622f215019e2609c3ee0bded1e6f1245 /activerecord/lib/active_record | |
parent | 063b058e28de226272bff64508f6a68d471fa398 (diff) | |
parent | 5f6370a81bd013b801f3e4842ffd466d756d127d (diff) | |
download | rails-0f2261f2d10afade350378779104cdf0fc09605c.tar.gz rails-0f2261f2d10afade350378779104cdf0fc09605c.tar.bz2 rails-0f2261f2d10afade350378779104cdf0fc09605c.zip |
Merge pull request #17139 from mfazekas/fix_becomes_changed_attributes
Always reset changed attributes in becomes
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/persistence.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index 3ca58523d7..35d1085f5a 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -208,7 +208,8 @@ module ActiveRecord def becomes(klass) became = klass.new became.instance_variable_set("@attributes", @attributes) - became.instance_variable_set("@changed_attributes", @changed_attributes) if defined?(@changed_attributes) + changed_attributes = @changed_attributes if defined?(@changed_attributes) + became.instance_variable_set("@changed_attributes", changed_attributes || {}) became.instance_variable_set("@new_record", new_record?) became.instance_variable_set("@destroyed", destroyed?) became.instance_variable_set("@errors", errors) |