我在rails-money方面遇到了麻烦
我的发票模型:
monetize :payment_cents此列存在于我的/clients/index上
<td><%= number_to_currency(invoice.payment_cents) %></td>我得到了数万而不是上千

我是否遗漏了什么,可能是迁移,将我的payments_cents重命名为:cents?或者在我的模型中定义如何显示货币。在/clients/show和form页面上,它显示如下

这很好!有人能帮上忙吗?
发布于 2020-07-17 18:14:28
您不必使用number_to_currency。
你可以使用他们自己的帮助器。
humanized_money_with_symbol(invoice.payment_cents)如果不起作用,请尝试以下方法。
invoice_payment = '%.2f' % (invoice.payment_cents.to_i/100.0) # -> 200.00
humanized_money_with_symbol(invoice_payment) # -> $200.00https://stackoverflow.com/questions/62926552
复制相似问题