Skip to content

Commit ded026b

Browse files
committed
Remove ActiveRecord::AttributeAssignment#assign_nested_parameter_attributes
The private `#assign_nested_parameter_attributes` was introduced in [774ff18][] (Dec 15, 2011), moved to `ActiveRecord::AttributeAssignment` in [ceb33f8][] (also Dec 15, 2011), then most recently modified in [2606fb3][] (Jan 23, 2015) when `ActiveModel::AttributeAssignment` was extracted. Support for `accepts_nested_attributes_for` (introduced in [ec8f045][] Feb 1, 2009) pre-dates those commits, and has evolved enough to cover this behavior in other ways. With its removal, Active Record's test suite still passes, so if it's a crucial piece of code to retain, we should expand the suite to exercise it. [774ff18]: rails@774ff18 [ceb33f8]: rails@ceb33f8 [2606fb3]: rails@2606fb3 [ec8f045]: rails@ec8f045
1 parent eac48e9 commit ded026b

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

activerecord/lib/active_record/attribute_assignment.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,21 @@ module ActiveRecord
44
module AttributeAssignment
55
private
66
def _assign_attributes(attributes)
7-
multi_parameter_attributes = nested_parameter_attributes = nil
7+
multi_parameter_attributes = nil
88

99
attributes.each do |k, v|
1010
key = k.to_s
1111

1212
if key.include?("(")
1313
(multi_parameter_attributes ||= {})[key] = v
14-
elsif v.is_a?(Hash)
15-
(nested_parameter_attributes ||= {})[key] = v
1614
else
1715
_assign_attribute(key, v)
1816
end
1917
end
2018

21-
assign_nested_parameter_attributes(nested_parameter_attributes) if nested_parameter_attributes
2219
assign_multiparameter_attributes(multi_parameter_attributes) if multi_parameter_attributes
2320
end
2421

25-
# Assign any deferred nested attributes after the base attributes have been set.
26-
def assign_nested_parameter_attributes(pairs)
27-
pairs.each { |k, v| _assign_attribute(k, v) }
28-
end
29-
3022
# Instantiates objects for all attribute classes that needs more than one constructor parameter. This is done
3123
# by calling new on the column type or aggregation type (through composed_of) object with these parameters.
3224
# So having the pairs written_on(1) = "2004", written_on(2) = "6", written_on(3) = "24", will instantiate

0 commit comments

Comments
 (0)