Given this simple Money
object query
Money.new(1000, "USD").to_s
=> "10.00"
How can I display the value with its symbol? I'm aware I can call money_object.symbol
but some currencies place the symbol before and other after the value. Im pretty sure there should be some easy method already for this? Haven't find it by reading into the documentation.
ActionView::Helpers::NumberHelper
hasnumber_to_currency
which should do the trick.if you are using
money-rails
, you have a lots of helpers:the currency_symbol helper method
This will render a span dom element with the default currency symbol.
the humanized_money helper method
This will render a formatted money value without the currency symbol and without the cents part if it contains only zeros (uses :no_cents_fi_whole flag).
humanize with symbol helper
This will render a formatted money value including the currency symbol and without the cents part if it contains only zeros.
get the money value without the cents part
This will render a formatted money value without the currency symbol and without the cents part.
get the money value without the cents part and including the currency symbol
This will render a formatted money value including the currency symbol and without the cents part.