Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.

Commit f4057b2

Browse files
committed
v1.2.4 - fix params type checking in nested attributes
1 parent 7567c9d commit f4057b2

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.2.4
2+
3+
* Fixed params type checking with nested attributes
4+
15
## 1.2.3
26

37
* Fixed ArgumentError with nested attributes

lib/active_record/mass_assignment_security/nested_attributes.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,9 @@ def assign_nested_attributes_for_one_to_one_association(association_name, attrib
7676
def assign_nested_attributes_for_collection_association(association_name, attributes_collection, assignment_opts = {})
7777
options = self.nested_attributes_options[association_name]
7878

79-
class_name = attributes_collection.class.name
80-
81-
if class_name == 'ActionController::Parameters'
79+
if attributes_collection.class.name == 'ActionController::Parameters'
8280
attributes_collection = attributes_collection.to_unsafe_h
83-
elsif !['Hash','Array'].include?(class_name)
81+
elsif !attributes_collection.is_a?(Hash) && !attributes_collection.is_a?(Array)
8482
raise ArgumentError, "ActionController::Parameters or Hash or Array expected, got #{attributes_collection.class.name} (#{attributes_collection.inspect})"
8583
end
8684

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module ProtectedAttributes
2-
VERSION = "1.2.3"
2+
VERSION = "1.2.4"
33
end

0 commit comments

Comments
 (0)