diff options
author | Edo Balvers <i@edo.me> | 2014-05-04 15:29:17 +0200 |
---|---|---|
committer | Edo Balvers <i@edo.me> | 2014-05-13 19:30:29 +0200 |
commit | 71c5d565b5b660c459966dabb99e491cbc7c2c99 (patch) | |
tree | 7f30b0eb27c6bd296524913e083c1d2b5bcc7d81 /activerecord/lib/active_record | |
parent | 977d36af8f84f467b6e4d21115cd4f84e50cfcb3 (diff) | |
download | rails-71c5d565b5b660c459966dabb99e491cbc7c2c99.tar.gz rails-71c5d565b5b660c459966dabb99e491cbc7c2c99.tar.bz2 rails-71c5d565b5b660c459966dabb99e491cbc7c2c99.zip |
Fix Baseclass becomes! subclass.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 24b33ab0a8..0458018951 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -73,7 +73,14 @@ module ActiveRecord def _update_record(values, id, id_was) # :nodoc: substitutes, binds = substitute_values values - um = @klass.unscoped.where(@klass.arel_table[@klass.primary_key].eq(id_was || id)).arel.compile_update(substitutes, @klass.primary_key) + + scope = @klass.unscoped + + if @klass.finder_needs_type_condition? + scope.unscope!(where: @klass.inheritance_column) + end + + um = scope.where(@klass.arel_table[@klass.primary_key].eq(id_was || id)).arel.compile_update(substitutes, @klass.primary_key) @klass.connection.update( um, |