- Lessons
Toxic Dependencies
- Lab Preview
Want everyone on your software team to learn this? Get completion tracking and compliance reporting with Hacksplaining for Teams. Free 14-day trial.
Train my teamattribute_assignment.rbdef _assign_attributes(attributes)
multi_parameter_attributes = nested_parameter_attributes = nil
attributes.each do |k, v|
key = k.to_s
if key.include?("(")
(multi_parameter_attributes ||= {})[key] = v
elsif v.is_a?(Hash)
(nested_parameter_attributes ||= {})[key] = v
else
_assign_attribute(key, v)
end
end
assign_nested_parameter_attributes(nested_parameter_attributes) if nested_parameter_attributes
assign_multiparameter_attributes(multi_parameter_attributes) if multi_parameter_attributes
end