I'm pretty new on rails 4 and I'm not really sure about how should be my join_table.
I've done the migration
rails g migration CreateJoinTableQuestionSubTopic question sub_topic
And I get this file
class CreateJoinTableQuestionSubTopic < ActiveRecord::Migration
def change
create_join_table :questions, :sub_topics do |t|
# t.index [:question_id, :sub_topic_id]
# t.index [:sub_topic_id, :question_id]
end
end
end
Why the two indexes are in comments ? I thought uncomment only one among these, is it the right way ?
Is there no need to write
t.column :question_id, :integer
t.column :sub_topic_id, :integer
Or/And
t.index :question_id
t.index :sub_topic_id
I would like to have a performant join table but I do not want to do it on old fashion way if there is a new one on rails 4
Thanks for your help