Rails钱列没有美分

时间:2015-04-27 16:34:20

标签: ruby-on-rails

我有一个Rails 3.2应用程序,我要求明年的预算请求。 amount字段是金钱 - 但是,我不想要任何小数。

我将使用number_to_currency显示数据。

我应该使用:

add_column :mytable, :amount, :decimal, :precision => 12, :scale => 0

或者:

add_column :mytable, :amount, :integer

感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

使用

add_column :mytable, :amount, :integer

number_to_currency(x/100)number_to_currency(x/100, {options})

这样可以避免任何舍入问题。

相关问题