mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
68926798a5
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
|
||
---|---|---|
.. | ||
serializers | ||
type | ||
validations | ||
attribute_assignment_test.rb | ||
attribute_methods_test.rb | ||
callbacks_test.rb | ||
conversion_test.rb | ||
dirty_test.rb | ||
errors_test.rb | ||
forbidden_attributes_protection_test.rb | ||
helper.rb | ||
lint_test.rb | ||
model_test.rb | ||
naming_test.rb | ||
railtie_test.rb | ||
secure_password_test.rb | ||
serialization_test.rb | ||
translation_test.rb | ||
validations_test.rb |