aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activemodel/lib/active_model/type/decimal.rb3
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