You can do it as follows:
create_table :courses do |t| t.string :name t.references :transferrable_as, references: :courses t.references :same_as, references: :courses t.timestamps end
or using t.belongs_to as an alias for t.references
You cannot add foreign_key: true to these two lines of links. If you want to mark them as foreign keys at the database level, you need to migrate with this:
add_foreign_key :courses, :courses, column: :transferrable_as_id add_foreign_key :courses, :courses, column: :same_as_id
Toby 1 Kenobi Aug 10 '15 at 16:11 2015-08-10 16:11
source share