diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2017-01-22 11:25:49 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-22 11:25:49 -0500 |
commit | b934f89fc3bac907e5bf49bff2b24e0d9cc41213 (patch) | |
tree | 75d2b39e5a2207070cf3e2f4af472e1c5a72339f | |
parent | 20107ff6c80a7e162adf22176eee811a59498126 (diff) | |
parent | 7ec30400e12d547ab573281c442ccb8a48d80495 (diff) | |
download | rails-b934f89fc3bac907e5bf49bff2b24e0d9cc41213.tar.gz rails-b934f89fc3bac907e5bf49bff2b24e0d9cc41213.tar.bz2 rails-b934f89fc3bac907e5bf49bff2b24e0d9cc41213.zip |
Merge pull request #27768 from kirs/am-decimal-cast
Make BigDecimal casting consistent on different platforms
-rw-r--r-- | activemodel/lib/active_model/type/decimal.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/type/decimal.rb b/activemodel/lib/active_model/type/decimal.rb index 6c5c0451c6..541a12c8a1 100644 --- a/activemodel/lib/active_model/type/decimal.rb +++ b/activemodel/lib/active_model/type/decimal.rb @@ -4,6 +4,7 @@ module ActiveModel module Type class Decimal < Value # :nodoc: include Helpers::Numeric + BIGDECIMAL_PRECISION = 18 def type :decimal @@ -21,7 +22,7 @@ module ActiveModel when ::Float convert_float_to_big_decimal(value) when ::Numeric, ::String - BigDecimal(value, precision.to_i) + BigDecimal(value, precision || BIGDECIMAL_PRECISION) else if value.respond_to?(:to_d) value.to_d |