If I have a has_many
and belongs_to
relationship between Questions and Answers:
class Question < ActiveRecord::Base
has_many :answers
end
class Answer < ActiveRecord::Base
belongs_to :question
end
Do I also need to modify the migration files to use "references":
class CreateAnswers < ActiveRecord::Migration
def self.up
create_table :answers do |t|
t.text :body
t.references :question
t.timestamps
end
end
def self.down
drop_table :answers
end
end
class CreateQuestions < ActiveRecord::Migration
def self.up
create_table :questions do |t|
t.text :body
t.references :answer
t.timestamps
end
end
def self.down
drop_table :questions
end
end