From 926c4b95e49cc65a1d7420392c95d2193b099965 Mon Sep 17 00:00:00 2001 From: wangjohn Date: Thu, 21 Mar 2013 17:10:17 -0400 Subject: Raising an error when nil or non-hash is passed to update_attributes. --- activerecord/lib/active_record/attribute_assignment.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'activerecord/lib') 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 ActiveModel::ForbiddenAttributesError # 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 = [] -- cgit v1.2.3