Rails: remove decimal from number_to_currency

ruby, ruby-on-rails

Solution

You can set the precision to 0 as documented here in the Rails API Docs.

number_to_currency(m.price, locale: :en, precision: 0)

Be aware that your prices will be rounded, anything from $38.50 to $39.49 will be displayed as $39.

Edit: Exchanged locale `:en_us` for `:en`, which might be enabled in more apps.

Problem

I have a float price: ``` number_to_currency(m.price, :locale => 'en_us') ``` I get: `$39.00` How can I remove `.00`, I want get: ``` $39 ```

Original source