Kristiyan Tsvetanov Kristiyan Tsvetanov - 1 year ago 218
Ruby Question

Rails, number to currency locale

I am trying to use


However, I do not know how to pass the locale if it is a variable.

In other words,
number_to_currency(100, locale: :us)
works, but
number_to_currency(100, locale: @locale)
@locale = "us"
, does not work.

Answer Source

"us" is a string, you need to pass in a symbol

use @locale.to_sym

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download