aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorwangjohn <wangjohn@mit.edu>2013-03-21 17:10:17 -0400
committerwangjohn <wangjohn@mit.edu>2013-06-25 20:56:58 -0700
commit926c4b95e49cc65a1d7420392c95d2193b099965 (patch)
tree910528e0c3283283d101a0b46ba91bbe452efc6b /activerecord/lib
parent9218770daa9ff0e3df56f75c98c053a6f8f751c7 (diff)
downloadrails-926c4b95e49cc65a1d7420392c95d2193b099965.tar.gz
rails-926c4b95e49cc65a1d7420392c95d2193b099965.tar.bz2
rails-926c4b95e49cc65a1d7420392c95d2193b099965.zip
Raising an error when nil or non-hash is passed to update_attributes.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/attribute_assignment.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/attribute_assignment.rb b/activerecord/lib/active_record/attribute_assignment.rb
index 75377bba57..53ce5f4952 100644
--- a/activerecord/lib/active_record/attribute_assignment.rb
+++ b/activerecord/lib/active_record/attribute_assignment.rb
@@ -13,7 +13,9 @@ module ActiveRecord
# of this method is +false+ an <tt>ActiveModel::ForbiddenAttributesError</tt>
# exception is raised.
def assign_attributes(new_attributes)
- return if new_attributes.blank?
+ if !new_attributes.respond_to?(:stringify_keys)
+ raise ArgumentError, "When assigning attributes, you must pass a hash as an argument."
+ end
attributes = new_attributes.stringify_keys
multi_parameter_attributes = []