diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-01-13 15:04:23 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-01-13 15:07:14 +0100 |
commit | e95031f55dd54945abebe6e9f8a12e428ada4146 (patch) | |
tree | 78980ad99b642e51df1b0fdeb366f53044ef1740 /activerecord/lib/active_record/persistence.rb | |
parent | ee4b5f1b8aedc59d94e72e1f0689de48e3b477bb (diff) | |
download | rails-e95031f55dd54945abebe6e9f8a12e428ada4146.tar.gz rails-e95031f55dd54945abebe6e9f8a12e428ada4146.tar.bz2 rails-e95031f55dd54945abebe6e9f8a12e428ada4146.zip |
fix bug in becomes! when changing from base to subclass. Closes #13272.
Diffstat (limited to 'activerecord/lib/active_record/persistence.rb')
-rw-r--r-- | activerecord/lib/active_record/persistence.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index 4669c072a1..460fbdb3f8 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -196,7 +196,11 @@ module ActiveRecord # share the same set of attributes. def becomes!(klass) became = becomes(klass) - became.public_send("#{klass.inheritance_column}=", klass.sti_name) unless self.class.descends_from_active_record? + sti_type = nil + if !klass.descends_from_active_record? + sti_type = klass.sti_name + end + became.public_send("#{klass.inheritance_column}=", sti_type) became end |