From 37303ea499c44fde9c552a701fe3c34cdedba0e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 18 Feb 2021 06:25:56 +0000 Subject: [PATCH] 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. --- activesupport/lib/active_support/locale/en.yml | 2 +- .../lib/active_support/number_helper/rounding_helper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/locale/en.yml b/activesupport/lib/active_support/locale/en.yml index 997541fc79..0453883a79 100644 --- a/activesupport/lib/active_support/locale/en.yml +++ b/activesupport/lib/active_support/locale/en.yml @@ -45,7 +45,7 @@ en: # Number of decimals, behind the separator (the number 1 with a precision of 2 gives: 1.00) precision: 3 # 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 # of the number of decimal digits (1234 with precision 2 becomes 1200, 1.23543 becomes 1.2) significant: false diff --git a/activesupport/lib/active_support/number_helper/rounding_helper.rb b/activesupport/lib/active_support/number_helper/rounding_helper.rb index cdf5535bd3..14deca13ea 100644 --- a/activesupport/lib/active_support/number_helper/rounding_helper.rb +++ b/activesupport/lib/active_support/number_helper/rounding_helper.rb @@ -13,7 +13,7 @@ module ActiveSupport precision = absolute_precision(number) 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 end