我有一个Rails 3.2应用程序,我要求明年的预算请求。 amount
字段是金钱 - 但是,我不想要任何小数。
我将使用number_to_currency
显示数据。
我应该使用:
add_column :mytable, :amount, :decimal, :precision => 12, :scale => 0
或者:
add_column :mytable, :amount, :integer
感谢您的帮助!
答案 0 :(得分:1)
使用
add_column :mytable, :amount, :integer
和number_to_currency(x/100)
或number_to_currency(x/100, {options})
这样可以避免任何舍入问题。