diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-09-24 11:56:50 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-09-24 11:56:50 -0300 |
commit | 16c7873c44cbced87b153bcbc7ac7ecfe950b53c (patch) | |
tree | 931dadff4c789f5b9e1ba0da6bddb8796d1a617c /activerecord/lib | |
parent | e029e0267206c603503db06eb48a0bbc3b2ed609 (diff) | |
parent | 926c4b95e49cc65a1d7420392c95d2193b099965 (diff) | |
download | rails-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.rb | 4 |
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 = [] |