diff options
author | Yves Senn <yves.senn@gmail.com> | 2012-09-02 17:19:50 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@garaio.com> | 2012-09-03 16:08:16 +0200 |
commit | 20574956d1ca73b5713bb857870fcd57cd09b35e (patch) | |
tree | 1aa4d44ea507b5cd41752cae64f8182913ab666a /activerecord/lib | |
parent | abd47c15b870ea3cdbe610a02df03e9425870417 (diff) | |
download | rails-20574956d1ca73b5713bb857870fcd57cd09b35e.tar.gz rails-20574956d1ca73b5713bb857870fcd57cd09b35e.tar.bz2 rails-20574956d1ca73b5713bb857870fcd57cd09b35e.zip |
set the configured #inheritance_column on #become (#7503)
I had to create a new table because I needed an STI table,
which does not have both a "type" and a "custom_type"
the test fails with:
1) Error:
test_alt_becomes_works_with_sti(InheritanceTest):
NoMethodError: undefined method `type=' for #<Cabbage id: 1, name: "my cucumber", custom_type: "Cucumber">
/Users/username/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:432:in `method_missing'
/Users/username/Projects/rails/activerecord/lib/active_record/attribute_methods.rb:100:in `method_missing'
/Users/username/Projects/rails/activerecord/lib/active_record/persistence.rb:165:in `becomes'
test/cases/inheritance_test.rb:134:in `test_becomes_works_with_sti'
test/cases/inheritance_test.rb:140:in `test_alt_becomes_works_with_sti'
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/persistence.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index ffb8513624..7bd65c180d 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -161,7 +161,7 @@ module ActiveRecord became.instance_variable_set("@new_record", new_record?) became.instance_variable_set("@destroyed", destroyed?) became.instance_variable_set("@errors", errors) - became.type = klass.name unless self.class.descends_from_active_record? + became.public_send("#{klass.inheritance_column}=", klass.name) unless self.class.descends_from_active_record? became end |