1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Avoid having to store complex object in the default translation file

This make possible for applications to use the safe mode of yaml to
load the translations files.

Fixes #41459.
This commit is contained in:
Rafael Mendonça França 2021-02-18 06:25:56 +00:00
parent 561fa1e165
commit 37303ea499
No known key found for this signature in database
GPG key ID: FC23B6D0F1EEE948
2 changed files with 2 additions and 2 deletions

View file

@ -45,7 +45,7 @@ en:
# Number of decimals, behind the separator (the number 1 with a precision of 2 gives: 1.00) # Number of decimals, behind the separator (the number 1 with a precision of 2 gives: 1.00)
precision: 3 precision: 3
# Determine how rounding is performed (see BigDecimal::mode) # Determine how rounding is performed (see BigDecimal::mode)
round_mode: !ruby/sym default round_mode: default
# If set to true, precision will mean the number of significant digits instead # If set to true, precision will mean the number of significant digits instead
# of the number of decimal digits (1234 with precision 2 becomes 1200, 1.23543 becomes 1.2) # of the number of decimal digits (1234 with precision 2 becomes 1200, 1.23543 becomes 1.2)
significant: false significant: false

View file

@ -13,7 +13,7 @@ module ActiveSupport
precision = absolute_precision(number) precision = absolute_precision(number)
return number unless precision return number unless precision
rounded_number = convert_to_decimal(number).round(precision, options.fetch(:round_mode, :default)) rounded_number = convert_to_decimal(number).round(precision, options.fetch(:round_mode, :default).to_sym)
rounded_number.zero? ? rounded_number.abs : rounded_number # prevent showing negative zeros rounded_number.zero? ? rounded_number.abs : rounded_number # prevent showing negative zeros
end end