mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Only dup attributes in activerecord attribute_assignment
This commit is contained in:
parent
8b59960cd4
commit
112c3ec0f5
2 changed files with 6 additions and 5 deletions
|
@ -31,7 +31,7 @@ module ActiveModel
|
||||||
end
|
end
|
||||||
return if new_attributes.empty?
|
return if new_attributes.empty?
|
||||||
|
|
||||||
_assign_attributes(sanitize_for_mass_assignment(new_attributes.dup))
|
_assign_attributes(sanitize_for_mass_assignment(new_attributes))
|
||||||
end
|
end
|
||||||
|
|
||||||
alias attributes= assign_attributes
|
alias attributes= assign_attributes
|
||||||
|
|
|
@ -10,17 +10,18 @@ module ActiveRecord
|
||||||
def _assign_attributes(attributes)
|
def _assign_attributes(attributes)
|
||||||
multi_parameter_attributes = {}
|
multi_parameter_attributes = {}
|
||||||
nested_parameter_attributes = {}
|
nested_parameter_attributes = {}
|
||||||
|
new_attributes = attributes.dup
|
||||||
|
|
||||||
attributes.each do |k, v|
|
new_attributes.each do |k, v|
|
||||||
key = k.to_s
|
key = k.to_s
|
||||||
|
|
||||||
if key.include?("(")
|
if key.include?("(")
|
||||||
multi_parameter_attributes[key] = attributes.delete(k)
|
multi_parameter_attributes[key] = new_attributes.delete(k)
|
||||||
elsif v.is_a?(Hash)
|
elsif v.is_a?(Hash)
|
||||||
nested_parameter_attributes[key] = attributes.delete(k)
|
nested_parameter_attributes[key] = new_attributes.delete(k)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
super(attributes)
|
super(new_attributes)
|
||||||
|
|
||||||
assign_nested_parameter_attributes(nested_parameter_attributes) unless nested_parameter_attributes.empty?
|
assign_nested_parameter_attributes(nested_parameter_attributes) unless nested_parameter_attributes.empty?
|
||||||
assign_multiparameter_attributes(multi_parameter_attributes) unless multi_parameter_attributes.empty?
|
assign_multiparameter_attributes(multi_parameter_attributes) unless multi_parameter_attributes.empty?
|
||||||
|
|
Loading…
Reference in a new issue