我知道number_to_currency
,但想用来number_with_precision
在数据库中输出某些产品的价格
我有一个prices
存储在一个数据库中,它有一个列类型decimal precision: 10, scale: 2
。价格存储为3.00
和2.99
我在输出价格时遇到问题 - 它正确输出2.99
价格,但只输出3.0
其他价格
您是否有任何关于如何让所有数字显示两位小数的信息,而不管它们的值如何?
谢谢!
这是我的代码:
#app/models/feature.rb
def price=(price)
number_with_precision price
end