Ruby on rails 如何在创建表时创建具有比例和精度的数字数据类型

Ruby on rails 如何在创建表时创建具有比例和精度的数字数据类型,ruby-on-rails,Ruby On Rails,我得到了这个错误 create_table :offers do |t| t.numeric(15,2) :total_sales t.numeric(10,2) :price t.numeric(10,2) :discount end 要使用十进制类型存储财务数据: create_offers.rb:12: syntax error, unexpected ':', expecting keyword_end t.numeric(15,2) :total_sales

我得到了这个错误

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

要使用十进制类型存储财务数据:

create_offers.rb:12: syntax error, unexpected ':', expecting keyword_end
      t.numeric(15,2) :total_sales
                       ^
/home/gvpmahesh/code/present-app/present/db/migrate/20161017072207_create_offers.rb:13: syntax error, unexpected ':', expecting keyword_end
      t.numeric(10,2) :price
                       ^
/home/gvpmahesh/code/present-app/present/db/migrate/20161017072207_create_offers.rb:14: syntax error, unexpected ':', expecting keyword_end
      t.numeric(10,2) :discount
                       ^

签出。

要使用十进制类型存储财务数据:

create_offers.rb:12: syntax error, unexpected ':', expecting keyword_end
      t.numeric(15,2) :total_sales
                       ^
/home/gvpmahesh/code/present-app/present/db/migrate/20161017072207_create_offers.rb:13: syntax error, unexpected ':', expecting keyword_end
      t.numeric(10,2) :price
                       ^
/home/gvpmahesh/code/present-app/present/db/migrate/20161017072207_create_offers.rb:14: syntax error, unexpected ':', expecting keyword_end
      t.numeric(10,2) :discount
                       ^
退房

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