diff options
author | Thomas Walpole <twalpole@gmail.com> | 2015-07-18 08:23:52 -0700 |
---|---|---|
committer | Thomas Walpole <twalpole@gmail.com> | 2015-07-18 08:23:52 -0700 |
commit | b5d4dd47deaae27e8f362bb9636246c5b4c56e5c (patch) | |
tree | 40a9aa6f8341d728d1ba918a449fd16c12a2cd3b /activerecord/lib | |
parent | 2a0a264b39eb99ddf444bbdacf3014868c8896cc (diff) | |
download | rails-b5d4dd47deaae27e8f362bb9636246c5b4c56e5c.tar.gz rails-b5d4dd47deaae27e8f362bb9636246c5b4c56e5c.tar.bz2 rails-b5d4dd47deaae27e8f362bb9636246c5b4c56e5c.zip |
Ensure that 'ActionController::Parameters' can still be passed to AR for collection associations
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/nested_attributes.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/nested_attributes.rb b/activerecord/lib/active_record/nested_attributes.rb index c337e1d18f..a6b76b25bf 100644 --- a/activerecord/lib/active_record/nested_attributes.rb +++ b/activerecord/lib/active_record/nested_attributes.rb @@ -445,6 +445,9 @@ module ActiveRecord # ]) def assign_nested_attributes_for_collection_association(association_name, attributes_collection) options = self.nested_attributes_options[association_name] + if attributes_collection.respond_to?(:permitted?) + attributes_collection = attributes_collection.to_h + end unless attributes_collection.is_a?(Hash) || attributes_collection.is_a?(Array) raise ArgumentError, "Hash or Array expected, got #{attributes_collection.class.name} (#{attributes_collection.inspect})" @@ -471,6 +474,9 @@ module ActiveRecord end attributes_collection.each do |attributes| + if attributes.respond_to?(:permitted?) + attributes = attributes.to_h + end attributes = attributes.with_indifferent_access if attributes['id'].blank? |