aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-09-24 11:56:50 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-09-24 11:56:50 -0300
commit16c7873c44cbced87b153bcbc7ac7ecfe950b53c (patch)
tree931dadff4c789f5b9e1ba0da6bddb8796d1a617c /activerecord/lib
parente029e0267206c603503db06eb48a0bbc3b2ed609 (diff)
parent926c4b95e49cc65a1d7420392c95d2193b099965 (diff)
downloadrails-16c7873c44cbced87b153bcbc7ac7ecfe950b53c.tar.gz
rails-16c7873c44cbced87b153bcbc7ac7ecfe950b53c.tar.bz2
rails-16c7873c44cbced87b153bcbc7ac7ecfe950b53c.zip
Merge pull request #9860 from wangjohn/update_attributes_throws_error_with_nil
Raising an error when nil is passed to update_attributes. Conflicts: activerecord/CHANGELOG.md
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 4f06955406..f201f86e22 100644
--- a/activerecord/lib/active_record/attribute_assignment.rb
+++ b/activerecord/lib/active_record/attribute_assignment.rb
@@ -12,7 +12,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 = []