aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-11-22 11:52:01 -0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-11-22 11:52:01 -0200
commitb313bcba07ea3c8b3dca3601bec23293f803efcc (patch)
tree714c4f01c8457dd10945a7867fe78216945445f1 /activerecord/lib/active_record
parent43dd9c87fd4c2054297a30b46e283ec69d17f30e (diff)
parent053bfa2304517fd2eb4e8e7dcb4eb9897f121271 (diff)
downloadrails-b313bcba07ea3c8b3dca3601bec23293f803efcc.tar.gz
rails-b313bcba07ea3c8b3dca3601bec23293f803efcc.tar.bz2
rails-b313bcba07ea3c8b3dca3601bec23293f803efcc.zip
Merge pull request #8291 from senny/8265_build_with_polymorphic_association
prevent mass assignment of polymorphic type when using `build` Conflicts: activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/associations/association.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb
index 99e7383d42..3f0e4ca999 100644
--- a/activerecord/lib/active_record/associations/association.rb
+++ b/activerecord/lib/active_record/associations/association.rb
@@ -232,7 +232,8 @@ module ActiveRecord
def build_record(attributes)
reflection.build_association(attributes) do |record|
- attributes = create_scope.except(*(record.changed - [reflection.foreign_key]))
+ skip_assign = [reflection.foreign_key, reflection.type].compact
+ attributes = create_scope.except(*(record.changed - skip_assign))
record.assign_attributes(attributes)
end
end