diff options
author | Derek Prior <derekprior@gmail.com> | 2015-12-23 14:04:52 -0500 |
---|---|---|
committer | Derek Prior <derekprior@gmail.com> | 2015-12-23 14:04:52 -0500 |
commit | d86c110b9324eebca1948046a7fa150f7b49bfe5 (patch) | |
tree | 4dbb6cc43de2dfa884aefbf2abb30c2efbfb89ca | |
parent | 2ad6deb5344abd77515f1c04edbd586a5538f705 (diff) | |
download | rails-d86c110b9324eebca1948046a7fa150f7b49bfe5.tar.gz rails-d86c110b9324eebca1948046a7fa150f7b49bfe5.tar.bz2 rails-d86c110b9324eebca1948046a7fa150f7b49bfe5.zip |
Add caveat to number_to_currency docs [ci skip]
I've worked on a few applications that have gone through the
internationalization process and had issues because they were using
`number_to_currency`. The minute a user is allowed to change their
locale, they can change the price displayed on a page from 10 US dollars
to 10 Mexican Pesos, which is far from the same amount of money.
Unlike other helpers that rely on i18n, `number_to_currency` does not
produce equivalent results when the locale is changed.
As I've explained this to a few groups of developers now, I thought it
might make for a good caveat in the docs.
-rw-r--r-- | actionview/lib/action_view/helpers/number_helper.rb | 8 | ||||
-rw-r--r-- | activesupport/lib/active_support/number_helper.rb | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/actionview/lib/action_view/helpers/number_helper.rb b/actionview/lib/action_view/helpers/number_helper.rb index d7182d1fac..0931a2a4c2 100644 --- a/actionview/lib/action_view/helpers/number_helper.rb +++ b/actionview/lib/action_view/helpers/number_helper.rb @@ -63,6 +63,14 @@ module ActionView # Formats a +number+ into a currency string (e.g., $13.65). You # can customize the format in the +options+ hash. # + # The currency unit and number formatting of the current locale will be used + # unless otherwise specified in the provided options. No currency conversion + # is performed. If the user is given a way to change their locale, they will + # also be able to change the relative value of the currency displayed with + # this helper. If your application will ever support multiple locales, you + # may want to specify a constant <tt>:locale</tt> option or consider + # using a library capable of currency conversion. + # # ==== Options # # * <tt>:locale</tt> - Sets the locale to be used for formatting diff --git a/activesupport/lib/active_support/number_helper.rb b/activesupport/lib/active_support/number_helper.rb index 248521e677..92a453be48 100644 --- a/activesupport/lib/active_support/number_helper.rb +++ b/activesupport/lib/active_support/number_helper.rb @@ -47,6 +47,14 @@ module ActiveSupport # Formats a +number+ into a currency string (e.g., $13.65). You # can customize the format in the +options+ hash. # + # The currency unit and number formatting of the current locale will be used + # unless otherwise specified in the provided options. No currency conversion + # is performed. If the user is given a way to change their locale, they will + # also be able to change the relative value of the currency displayed with + # this helper. If your application will ever support multiple locales, you + # may want to specify a constant <tt>:locale</tt> option or consider + # using a library capable of currency conversion. + # # ==== Options # # * <tt>:locale</tt> - Sets the locale to be used for formatting |