aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-07-18 13:21:06 -0500
committerSean Griffin <sean@seantheprogrammer.com>2015-07-18 13:21:06 -0500
commit3f1c5d39c01e13bcf9e34865f00ded56a3a321fc (patch)
tree8dadb882509bedd79835122cbfe12ba4e1394749 /activerecord/lib/active_record
parent7550f0a016ee6647aaa76c0c0ae30bebc3867288 (diff)
parentb5d4dd47deaae27e8f362bb9636246c5b4c56e5c (diff)
downloadrails-3f1c5d39c01e13bcf9e34865f00ded56a3a321fc.tar.gz
rails-3f1c5d39c01e13bcf9e34865f00ded56a3a321fc.tar.bz2
rails-3f1c5d39c01e13bcf9e34865f00ded56a3a321fc.zip
Merge pull request #20932 from twalpole/collection_association_parameters
Ensure that 'ActionController::Parameters' can still be passed to AR …
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/nested_attributes.rb6
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?