Skip to content
Browse files

AR::Base#attributes= is just an alias for AR::Base#assign_attributes

  • Loading branch information...
1 parent 731d809 commit 97338d581484521263f066db3e79775a5c311e83 @guilleiguaran committed Sep 19, 2012
Showing with 4 additions and 10 deletions.
  1. +4 −10 activerecord/lib/active_record/attribute_assignment.rb
View
14 activerecord/lib/active_record/attribute_assignment.rb
@@ -5,20 +5,12 @@ module AttributeAssignment
include ActiveModel::DeprecatedMassAssignmentSecurity
include ActiveModel::ForbiddenAttributesProtection
- # Allows you to set all the attributes at once by passing in a hash with keys
- # matching the attribute names (which again matches the column names).
+ # Allows you to set all the attributes by passing in a hash of attributes with
+ # keys matching the attribute names (which again matches the column names)
#
# If the passed hash responds to permitted? method and the return value
# of this method is false an ActiveModel::ForbiddenAttributesError exception
# is raised.
- def attributes=(new_attributes)
- return unless new_attributes.is_a?(Hash)
-
- assign_attributes(new_attributes)
- end
-
- # Allows you to set all the attributes by passing in a hash of attributes with
- # keys matching the attribute names (which again matches the column names)
def assign_attributes(new_attributes)
return if new_attributes.blank?
@@ -42,6 +34,8 @@ def assign_attributes(new_attributes)
assign_multiparameter_attributes(multi_parameter_attributes) unless multi_parameter_attributes.empty?
end
+ alias attributes= assign_attributes
+
private
def _assign_attribute(k, v)

0 comments on commit 97338d5

Please sign in to comment.
Something went wrong with that request. Please try again.