一世
我在运行rake db:migrate之后添加了has_many和belongs_to . 我添加了这些关联,然后再次使用db:migrate . 没有生成索引 . 你能告诉我为什么吗?
以下是我的协会
class Developer <ActiveRecord :: Base has_many:evaluations has_many:final_scores belongs_to:supervisor end
class Evaluation <ActiveRecord :: Base belongs_to:developer belongs_to:supervisor end
class FinalScore <ActiveRecord :: Base belongs_to:developer end
class Supervisor <ActiveRecord :: Base has_many:开发人员has_many:评估:through =>:开发人员结束
2 回答
看看关于这个主题的官方栏目指南:http://edgeguides.rubyonrails.org/association_basics.html#the-has-many-association
在那里,您可以看到需要更改生成的迁移文件并自行添加字段 .
这blog有助于更好地理解 . 您可能错过了迁移文件中的某些内容 .