From b01740f9088be49b49f7ed0ca7b73ebbde87bd97 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Mon, 6 Jun 2016 15:51:57 +0900 Subject: Use `inspect` in `type_cast_for_schema` for date/time and decimal values Currently dumping defaults on schema is inconsistent. Before: ```ruby create_table "defaults", force: :cascade do |t| t.string "string_with_default", default: "Hello!" t.date "date_with_default", default: '2014-06-05' t.datetime "datetime_with_default", default: '2014-06-05 07:17:04' t.time "time_with_default", default: '2000-01-01 07:17:04' t.decimal "decimal_with_default", default: 1234567890 end ``` After: ```ruby create_table "defaults", force: :cascade do |t| t.string "string_with_default", default: "Hello!" t.date "date_with_default", default: "2014-06-05" t.datetime "datetime_with_default", default: "2014-06-05 07:17:04" t.time "time_with_default", default: "2000-01-01 07:17:04" t.decimal "decimal_with_default", default: "1234567890" end ``` --- activemodel/lib/active_model/type/date.rb | 2 +- activemodel/lib/active_model/type/helpers/time_value.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/type/date.rb b/activemodel/lib/active_model/type/date.rb index 6e313fbca8..eefd080351 100644 --- a/activemodel/lib/active_model/type/date.rb +++ b/activemodel/lib/active_model/type/date.rb @@ -12,7 +12,7 @@ module ActiveModel end def type_cast_for_schema(value) - "'#{value.to_s(:db)}'" + value.to_s(:db).inspect end private diff --git a/activemodel/lib/active_model/type/helpers/time_value.rb b/activemodel/lib/active_model/type/helpers/time_value.rb index 721f9543ed..8c9b092925 100644 --- a/activemodel/lib/active_model/type/helpers/time_value.rb +++ b/activemodel/lib/active_model/type/helpers/time_value.rb @@ -38,7 +38,7 @@ module ActiveModel end def type_cast_for_schema(value) - "'#{value.to_s(:db)}'" + value.to_s(:db).inspect end def user_input_in_time_zone(value) -- cgit v1.2.3 From 34867115b0b8c76c3d0a94f0f6de51c54fae2f94 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 15 Feb 2017 10:38:31 -0500 Subject: Indicate units of 'limit' in 'Integer' error message. --- activemodel/lib/active_model/type/integer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/type/integer.rb b/activemodel/lib/active_model/type/integer.rb index 230e45ba60..106b5d966c 100644 --- a/activemodel/lib/active_model/type/integer.rb +++ b/activemodel/lib/active_model/type/integer.rb @@ -48,7 +48,7 @@ module ActiveModel def ensure_in_range(value) unless range.cover?(value) - raise ActiveModel::RangeError, "#{value} is out of range for #{self.class} with limit #{_limit}" + raise ActiveModel::RangeError, "#{value} is out of range for #{self.class} with limit #{_limit} bytes" end end -- cgit v1.2.3 From d57356bd5ad0d64ed3fb530d722f32107ea60cdf Mon Sep 17 00:00:00 2001 From: Sen Zhang Date: Wed, 15 Feb 2017 14:29:04 -0800 Subject: change ActiveModel::Validation to ActiveModel::Validations in comments --- activemodel/lib/active_model/validations/absence.rb | 2 +- activemodel/lib/active_model/validations/acceptance.rb | 2 +- activemodel/lib/active_model/validations/confirmation.rb | 2 +- activemodel/lib/active_model/validations/exclusion.rb | 2 +- activemodel/lib/active_model/validations/format.rb | 2 +- activemodel/lib/active_model/validations/inclusion.rb | 2 +- activemodel/lib/active_model/validations/length.rb | 2 +- activemodel/lib/active_model/validations/numericality.rb | 2 +- activemodel/lib/active_model/validations/presence.rb | 2 +- activemodel/lib/active_model/validations/with.rb | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/validations/absence.rb b/activemodel/lib/active_model/validations/absence.rb index 75bf655578..4618f46e30 100644 --- a/activemodel/lib/active_model/validations/absence.rb +++ b/activemodel/lib/active_model/validations/absence.rb @@ -22,7 +22,7 @@ module ActiveModel # # There is also a list of default options supported by every validator: # +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+. - # See ActiveModel::Validation#validates for more information + # See ActiveModel::Validations#validates for more information def validates_absence_of(*attr_names) validates_with AbsenceValidator, _merge_attributes(attr_names) end diff --git a/activemodel/lib/active_model/validations/acceptance.rb b/activemodel/lib/active_model/validations/acceptance.rb index e11005b9ba..a26c37daa5 100644 --- a/activemodel/lib/active_model/validations/acceptance.rb +++ b/activemodel/lib/active_model/validations/acceptance.rb @@ -95,7 +95,7 @@ module ActiveModel # # There is also a list of default options supported by every validator: # +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+. - # See ActiveModel::Validation#validates for more information. + # See ActiveModel::Validations#validates for more information. def validates_acceptance_of(*attr_names) validates_with AcceptanceValidator, _merge_attributes(attr_names) end diff --git a/activemodel/lib/active_model/validations/confirmation.rb b/activemodel/lib/active_model/validations/confirmation.rb index 33ca6f6946..03585bf5e1 100644 --- a/activemodel/lib/active_model/validations/confirmation.rb +++ b/activemodel/lib/active_model/validations/confirmation.rb @@ -69,7 +69,7 @@ module ActiveModel # # There is also a list of default options supported by every validator: # +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+. - # See ActiveModel::Validation#validates for more information + # See ActiveModel::Validations#validates for more information def validates_confirmation_of(*attr_names) validates_with ConfirmationValidator, _merge_attributes(attr_names) end diff --git a/activemodel/lib/active_model/validations/exclusion.rb b/activemodel/lib/active_model/validations/exclusion.rb index 82a1893823..b7156ba802 100644 --- a/activemodel/lib/active_model/validations/exclusion.rb +++ b/activemodel/lib/active_model/validations/exclusion.rb @@ -38,7 +38,7 @@ module ActiveModel # # There is also a list of default options supported by every validator: # +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+. - # See ActiveModel::Validation#validates for more information + # See ActiveModel::Validations#validates for more information def validates_exclusion_of(*attr_names) validates_with ExclusionValidator, _merge_attributes(attr_names) end diff --git a/activemodel/lib/active_model/validations/format.rb b/activemodel/lib/active_model/validations/format.rb index fa183885ab..b4b8d9f33c 100644 --- a/activemodel/lib/active_model/validations/format.rb +++ b/activemodel/lib/active_model/validations/format.rb @@ -104,7 +104,7 @@ module ActiveModel # # There is also a list of default options supported by every validator: # +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+. - # See ActiveModel::Validation#validates for more information + # See ActiveModel::Validations#validates for more information def validates_format_of(*attr_names) validates_with FormatValidator, _merge_attributes(attr_names) end diff --git a/activemodel/lib/active_model/validations/inclusion.rb b/activemodel/lib/active_model/validations/inclusion.rb index 0ea6012a5d..c6c5bae649 100644 --- a/activemodel/lib/active_model/validations/inclusion.rb +++ b/activemodel/lib/active_model/validations/inclusion.rb @@ -36,7 +36,7 @@ module ActiveModel # # There is also a list of default options supported by every validator: # +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+. - # See ActiveModel::Validation#validates for more information + # See ActiveModel::Validations#validates for more information def validates_inclusion_of(*attr_names) validates_with InclusionValidator, _merge_attributes(attr_names) end diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb index 739f8190cc..940c58f3a7 100644 --- a/activemodel/lib/active_model/validations/length.rb +++ b/activemodel/lib/active_model/validations/length.rb @@ -110,7 +110,7 @@ module ActiveModel # # There is also a list of default options supported by every validator: # +:if+, +:unless+, +:on+ and +:strict+. - # See ActiveModel::Validation#validates for more information + # See ActiveModel::Validations#validates for more information def validates_length_of(*attr_names) validates_with LengthValidator, _merge_attributes(attr_names) end diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb index 2297faaee5..4bfc402069 100644 --- a/activemodel/lib/active_model/validations/numericality.rb +++ b/activemodel/lib/active_model/validations/numericality.rb @@ -134,7 +134,7 @@ module ActiveModel # # There is also a list of default options supported by every validator: # +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+ . - # See ActiveModel::Validation#validates for more information + # See ActiveModel::Validations#validates for more information # # The following checks can also be supplied with a proc or a symbol which # corresponds to a method: diff --git a/activemodel/lib/active_model/validations/presence.rb b/activemodel/lib/active_model/validations/presence.rb index 0c11cf4265..6e8a434bbe 100644 --- a/activemodel/lib/active_model/validations/presence.rb +++ b/activemodel/lib/active_model/validations/presence.rb @@ -29,7 +29,7 @@ module ActiveModel # # There is also a list of default options supported by every validator: # +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+. - # See ActiveModel::Validation#validates for more information + # See ActiveModel::Validations#validates for more information def validates_presence_of(*attr_names) validates_with PresenceValidator, _merge_attributes(attr_names) end diff --git a/activemodel/lib/active_model/validations/with.rb b/activemodel/lib/active_model/validations/with.rb index e3f7a9bcb2..9227dd06ff 100644 --- a/activemodel/lib/active_model/validations/with.rb +++ b/activemodel/lib/active_model/validations/with.rb @@ -61,7 +61,7 @@ module ActiveModel # The method, proc or string should return or evaluate to a +true+ or # +false+ value. # * :strict - Specifies whether validation should be strict. - # See ActiveModel::Validation#validates! for more information. + # See ActiveModel::Validations#validates! for more information. # # If you pass any additional configuration options, they will be passed # to the class and available as +options+: -- cgit v1.2.3 From 33860b3556b0e922f16ebec1fc7b985bc4c23d17 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Fri, 17 Feb 2017 23:11:01 +0900 Subject: Remove `:doc:` for `NumericalityValidator` [ci skip] The `:doc:` was added in cdb9d7f but `NumericalityValidator` is already `:nodoc:` class. `:doc:` is unneeded. https://github.com/rails/rails/blob/master/activemodel/lib/active_model/validations/numericality.rb#L3 --- activemodel/lib/active_model/validations/numericality.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb index 4bfc402069..30a9ef472d 100644 --- a/activemodel/lib/active_model/validations/numericality.rb +++ b/activemodel/lib/active_model/validations/numericality.rb @@ -63,27 +63,27 @@ module ActiveModel private - def is_number?(raw_value) # :doc: + def is_number?(raw_value) !parse_raw_value_as_a_number(raw_value).nil? rescue ArgumentError, TypeError false end - def parse_raw_value_as_a_number(raw_value) # :doc: + def parse_raw_value_as_a_number(raw_value) Kernel.Float(raw_value) if raw_value !~ /\A0[xX]/ end - def is_integer?(raw_value) # :doc: + def is_integer?(raw_value) /\A[+-]?\d+\z/ === raw_value.to_s end - def filtered_options(value) # :doc: + def filtered_options(value) filtered = options.except(*RESERVED_OPTIONS) filtered[:value] = value filtered end - def allow_only_integer?(record) # :doc: + def allow_only_integer?(record) case options[:only_integer] when Symbol record.send(options[:only_integer]) -- cgit v1.2.3 From b0be7792adf58e092b7f615ecbf3339ea70ee689 Mon Sep 17 00:00:00 2001 From: namusyaka Date: Fri, 17 Feb 2017 22:15:01 +0900 Subject: Avoid converting integer as a string into float --- activemodel/lib/active_model/validations/numericality.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb index 30a9ef472d..995b331245 100644 --- a/activemodel/lib/active_model/validations/numericality.rb +++ b/activemodel/lib/active_model/validations/numericality.rb @@ -70,6 +70,7 @@ module ActiveModel end def parse_raw_value_as_a_number(raw_value) + return raw_value.to_i if is_integer?(raw_value) Kernel.Float(raw_value) if raw_value !~ /\A0[xX]/ end -- cgit v1.2.3 From 0b157f8ded03ef988308a135e12c9bc99a1cc703 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Tue, 21 Feb 2017 19:59:56 +0900 Subject: Fix `define_attribute_method` with Symbol in AR This issue is only appear when you try to call `define_attribute_method` and passing a symbol in Active Record. It does not appear in isolation in Active Model itself. Before this patch, when you run `User.define_attribute_method :foo`, you will get: NoMethodError: undefined method `unpack' for :foo:Symbol from activerecord/lib/active_record/attribute_methods/read.rb:28:in `define_method_attribute' from activerecord/lib/active_record/attribute_methods/primary_key.rb:61:in `define_method_attribute' from activemodel/lib/active_model/attribute_methods.rb:292:in `block in define_attribute_method' from activemodel/lib/active_model/attribute_methods.rb:285:in `each' from activemodel/lib/active_model/attribute_methods.rb:285:in `define_attribute_method' This patch contains both a fix in Active Model and a test in Active Record for this error. --- activemodel/lib/active_model/attribute_methods.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb index 09825cf861..166c6ac21f 100644 --- a/activemodel/lib/active_model/attribute_methods.rb +++ b/activemodel/lib/active_model/attribute_methods.rb @@ -289,7 +289,7 @@ module ActiveModel generate_method = "define_method_#{matcher.method_missing_target}" if respond_to?(generate_method, true) - send(generate_method, attr_name) + send(generate_method, attr_name.to_s) else define_proxy_call true, generated_attribute_methods, method_name, matcher.method_missing_target, attr_name.to_s end -- cgit v1.2.3 From f4acdd83ff76e2338895073ed914c525e7bb33b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 23 Feb 2017 14:53:12 -0500 Subject: Preparing for 5.1.0.beta1 release --- activemodel/lib/active_model/gem_version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/gem_version.rb b/activemodel/lib/active_model/gem_version.rb index 4a8ee915cf..6a2ab2a8e5 100644 --- a/activemodel/lib/active_model/gem_version.rb +++ b/activemodel/lib/active_model/gem_version.rb @@ -8,7 +8,7 @@ module ActiveModel MAJOR = 5 MINOR = 1 TINY = 0 - PRE = "alpha" + PRE = "beta1" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end -- cgit v1.2.3 From 68926798a53bb98e56efe9a96e321a33cc0fa995 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Wed, 21 Dec 2016 15:33:37 -0800 Subject: Fix invalid string Decimal casting under ruby 2.4 In Ruby 2.4, BigDecimal(), as used by the Decimal cast, was changed so that it will raise ArgumentError when passed an invalid string, in order to be more consistent with Integer(), Float(), etc. The other numeric types use ex. to_i and to_f. Unfortunately, we can't simply change BigDecimal() to to_d. String#to_d raises errors like BigDecimal(), unlike all the other to_* methods (this should probably be filed as a ruby bug). Instead, this simulates the existing behaviour and the behaviour of the other to_* methods by finding a numeric string at the start of the passed in value, and parsing that using BigDecimal(). See also https://bugs.ruby-lang.org/issues/10286 https://github.com/ruby/bigdecimal/commit/3081a627cebdc1fc119425c7a9f009dbb6bec8e8 --- activemodel/lib/active_model/type/decimal.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/type/decimal.rb b/activemodel/lib/active_model/type/decimal.rb index 541a12c8a1..b4ba8d4b1f 100644 --- a/activemodel/lib/active_model/type/decimal.rb +++ b/activemodel/lib/active_model/type/decimal.rb @@ -21,8 +21,10 @@ module ActiveModel case value when ::Float convert_float_to_big_decimal(value) - when ::Numeric, ::String + when ::Numeric BigDecimal(value, precision || BIGDECIMAL_PRECISION) + when ::String + value.to_d rescue BigDecimal(0) else if value.respond_to?(:to_d) value.to_d -- cgit v1.2.3 From 0683552b15becd6949ab4e125d9790f1b65b7415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 24 Feb 2017 19:28:41 -0500 Subject: Match the behavior of bigdecimal after https://github.com/ruby/bigdecimal/pull/55 --- activemodel/lib/active_model/type/decimal.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/type/decimal.rb b/activemodel/lib/active_model/type/decimal.rb index b4ba8d4b1f..e6805c5f6b 100644 --- a/activemodel/lib/active_model/type/decimal.rb +++ b/activemodel/lib/active_model/type/decimal.rb @@ -24,7 +24,11 @@ module ActiveModel when ::Numeric BigDecimal(value, precision || BIGDECIMAL_PRECISION) when ::String - value.to_d rescue BigDecimal(0) + begin + value.to_d + rescue ArgumentError + BigDecimal(0) + end else if value.respond_to?(:to_d) value.to_d -- cgit v1.2.3 From ddb798acaab48bc0ed278c9f3c1ace78722e4217 Mon Sep 17 00:00:00 2001 From: jasl Date: Sat, 11 Mar 2017 10:17:46 +0800 Subject: Remove non-exists method delegation and correct doc --- activemodel/lib/active_model/type.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/type.rb b/activemodel/lib/active_model/type.rb index b8e6d2376b..095801d8f0 100644 --- a/activemodel/lib/active_model/type.rb +++ b/activemodel/lib/active_model/type.rb @@ -21,16 +21,8 @@ module ActiveModel class << self attr_accessor :registry # :nodoc: - delegate :add_modifier, to: :registry - # Add a new type to the registry, allowing it to be referenced as a - # symbol by ActiveRecord::Attributes::ClassMethods#attribute. If your - # type is only meant to be used with a specific database adapter, you can - # do so by passing +adapter: :postgresql+. If your type has the same - # name as a native type for the current adapter, an exception will be - # raised unless you specify an +:override+ option. +override: true+ will - # cause your type to be used instead of the native type. +override: - # false+ will cause the native type to be used over yours if one exists. + # Add a new type to the registry, allowing it to be get through ActiveModel::Type#lookup def register(type_name, klass = nil, **options, &block) registry.register(type_name, klass, **options, &block) end -- cgit v1.2.3 From 6c08d480f13d3332c878ca8a120a03fcd78f7ba2 Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Wed, 22 Mar 2017 10:11:39 +1030 Subject: Start Rails 5.2 development --- activemodel/lib/active_model/gem_version.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/gem_version.rb b/activemodel/lib/active_model/gem_version.rb index 6a2ab2a8e5..67bdfaa643 100644 --- a/activemodel/lib/active_model/gem_version.rb +++ b/activemodel/lib/active_model/gem_version.rb @@ -6,9 +6,9 @@ module ActiveModel module VERSION MAJOR = 5 - MINOR = 1 + MINOR = 2 TINY = 0 - PRE = "beta1" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end -- cgit v1.2.3 From 01269aede398f63e5ef68ebe0f0dafbc472c686e Mon Sep 17 00:00:00 2001 From: bogdanvlviv Date: Tue, 28 Mar 2017 12:05:14 +0300 Subject: Fix ActiveModel::Errors #keys, #values Before: person.errors.keys # => [] person.errors.values # => [] person.errors[:name] # => [] person.errors.keys # => [:name] person.errors.values # => [[]] After: person.errors.keys # => [] person.errors.values # => [] person.errors[:name] # => [] person.errors.keys # => [] person.errors.values # => [] Related to #23468 --- activemodel/lib/active_model/errors.rb | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 9df4ca51fe..5d3472802b 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -132,15 +132,6 @@ module ActiveModel # # person.errors[:name] # => ["cannot be nil"] # person.errors['name'] # => ["cannot be nil"] - # - # Note that, if you try to get errors of an attribute which has - # no errors associated with it, this method will instantiate - # an empty error list for it and +keys+ will return an array - # of error keys which includes this attribute. - # - # person.errors.keys # => [] - # person.errors[:name] # => [] - # person.errors.keys # => [:name] def [](attribute) messages[attribute.to_sym] end @@ -181,7 +172,9 @@ module ActiveModel # person.errors.messages # => {:name=>["cannot be nil", "must be specified"]} # person.errors.values # => [["cannot be nil", "must be specified"]] def values - messages.values + messages.reject do |key, value| + value.empty? + end.values end # Returns all message keys. @@ -189,7 +182,9 @@ module ActiveModel # person.errors.messages # => {:name=>["cannot be nil", "must be specified"]} # person.errors.keys # => [:name] def keys - messages.keys + messages.reject do |key, value| + value.empty? + end.keys end # Returns +true+ if no errors are found, +false+ otherwise. -- cgit v1.2.3 From d1ca18d21f3c173af34dfdc3fa34de577178fee9 Mon Sep 17 00:00:00 2001 From: Tsukuru Tanimichi Date: Sun, 2 Apr 2017 13:42:14 +0900 Subject: 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. ``` --- activemodel/lib/active_model/attribute_assignment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activemodel/lib') 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)) -- cgit v1.2.3