0

When I use money-rails for converting the integer hourly_wage_salary_cents column into a thousands money object. It removes 2 zeros from the number itself. Instead of getting $50,000, I am getting $500.00 or $500. How can I format the money object to include the correct comma places for numbers larger than hundreds.

show.html.erb

<h6><%= fa_icon 'money' %> Salary/Wage</h6>
        <p>
          <%= money_without_cents @job.hourly_wage_salary_cents %>
        </p>

job model

monetize :hourly_wage_salary, :as => "hourly_wage_salary_cents"
Johnny C
  • 121
  • 1
  • 1
  • 11
  • 1
    by default when you create a money object with `new` method, it takes that amount as cents. (or any other subunit). so, `Money.new(5000, 'USD')` is actually five thousand cents and this is 50 bucks, not 5 thousand. – marmeladze Feb 18 '18 at 20:51

1 Answers1

0

By default the money object will have the amount in cents. So, you need to take this in account when saving or setting the value.

You can find more details in this answer. Some options to do the formatting:

mmsilviu
  • 1,211
  • 15
  • 25