diff options
author | Tsukuru Tanimichi <ttanimichi@users.noreply.github.com> | 2017-04-02 13:42:14 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-02 13:42:14 +0900 |
commit | d1ca18d21f3c173af34dfdc3fa34de577178fee9 (patch) | |
tree | 0e0c5ebf37262d5988fb626ef952b13941626fe4 /activemodel/lib | |
parent | eb180f14f46d11963fa2a725a5657eb16d5900ca (diff) | |
download | rails-d1ca18d21f3c173af34dfdc3fa34de577178fee9.tar.gz rails-d1ca18d21f3c173af34dfdc3fa34de577178fee9.tar.bz2 rails-d1ca18d21f3c173af34dfdc3fa34de577178fee9.zip |
No need to check nil
```ruby
nil.respond_to?(:stringify_keys) # => false
```
```ruby
include ActiveModel::AttributeAssignment
Object.new.assign_attributes(nil) # => ArgumentError: When assigning attributes, you must pass a hash as an argument.
```
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/attribute_assignment.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/attribute_assignment.rb b/activemodel/lib/active_model/attribute_assignment.rb index 7dad3b6dff..ee130df989 100644 --- a/activemodel/lib/active_model/attribute_assignment.rb +++ b/activemodel/lib/active_model/attribute_assignment.rb @@ -27,7 +27,7 @@ module ActiveModel if !new_attributes.respond_to?(:stringify_keys) raise ArgumentError, "When assigning attributes, you must pass a hash as an argument." end - return if new_attributes.nil? || new_attributes.empty? + return if new_attributes.empty? attributes = new_attributes.stringify_keys _assign_attributes(sanitize_for_mass_assignment(attributes)) |