如何在创建表时创建具有比例和精度的数值数据类型

时间:2016-10-17 07:30:00

标签: ruby-on-rails

static List myLog

我收到此错误

create_table :offers do |t|
  t.numeric(15,2) :total_sales
  t.numeric(10,2) :price
  t.numeric(10,2) :discount
end

2 个答案:

答案 0 :(得分:1)

您想使用小数类型来存储财务数据:

create_table :offers do |t|
  t.decimal :total_sales, precision: 15, scale: 2 
  t.decimal :price,       precision: 10, scale: 2 
  t.decimal :discount,    precision: 10, scale: 2 
end

查看official guides on migrations

答案 1 :(得分:1)

return di.GetFiles()
       .Union(di.GetDirectories().Select(d => GetNewestFile()))
       .OrderByDescending(f => (f == null ? DateTime.MinValue : f.LastWriteTime))
       .FirstOrDefault();