Nei*_*eil 4 ruby haml datamapper sinatra
我有一个模型,称为交付:
property :id, Serial
property :created_at, DateTime
property :updated_at, DateTime
property :price, BigDecimal, :precision => 10, :scale => 2
Run Code Online (Sandbox Code Playgroud)
交付有一个价格,在SQLite中查看的价格是5.49,6.95,4.95等
在输出中显示此信息(以haml编码)时,来自delivery.price的值显示为0.695E1,0.495E1等
知道为什么他们以这种格式显示,以及如何最好地正确显示它们.
所有帮助表示赞赏!
转换为string(BigDecimal#to_s)采用格式参数:
>> n = BigDecimal.new('5.49')
=> #<BigDecimal:100502958,'0.549E1',18(18)>
>> n.to_s
=> "0.549E1"
>> n.to_s('F')
=> "5.49"
Run Code Online (Sandbox Code Playgroud)