Rails migration: t.references with alternative name?

前端 未结 5 1054
情歌与酒
情歌与酒 2021-01-30 05:48

So I have a create_table like this for Courses at a School:

create_table :courses do |t|
  t.string :name
  t.references :course
  t.timestamps
end
5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-30 06:29

    I don't think references accepts the :as option, but you can create your columns manually...

    create_table :courses do |t| 
      t.string  :name 
      t.integer :course1_id
      t.integer :course2_id 
      t.timestamps 
    end 
    

提交回复
热议问题