File tree 1 file changed +7
-13
lines changed
activerecord/lib/active_record
1 file changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -6,30 +6,24 @@ module ActiveRecord
6
6
module AttributeAssignment
7
7
include ActiveModel ::AttributeAssignment
8
8
9
- def assign_attributes ( attributes )
10
- super ( attributes . dup )
11
- end
12
-
13
- alias attributes = assign_attributes
14
-
15
9
private
16
10
def _assign_attributes ( attributes )
17
- multi_parameter_attributes = { }
18
- nested_parameter_attributes = { }
11
+ multi_parameter_attributes = nested_parameter_attributes = nil
19
12
20
13
attributes . each do |k , v |
21
14
key = k . to_s
22
15
23
16
if key . include? ( "(" )
24
- multi_parameter_attributes [ key ] = attributes . delete ( k )
17
+ ( multi_parameter_attributes ||= { } ) [ key ] = v
25
18
elsif v . is_a? ( Hash )
26
- nested_parameter_attributes [ key ] = attributes . delete ( k )
19
+ ( nested_parameter_attributes ||= { } ) [ key ] = v
20
+ else
21
+ _assign_attribute ( key , v )
27
22
end
28
23
end
29
- super ( attributes )
30
24
31
- assign_nested_parameter_attributes ( nested_parameter_attributes ) unless nested_parameter_attributes . empty?
32
- assign_multiparameter_attributes ( multi_parameter_attributes ) unless multi_parameter_attributes . empty?
25
+ assign_nested_parameter_attributes ( nested_parameter_attributes ) if nested_parameter_attributes
26
+ assign_multiparameter_attributes ( multi_parameter_attributes ) if multi_parameter_attributes
33
27
end
34
28
35
29
# Assign any deferred nested attributes after the base attributes have been set.
You can’t perform that action at this time.
0 commit comments