在之前的一些stackoverflow问题中,例如:
Rails 3 has_and_belongs_to_many migration
建议设置:id => false表示此关联的连接表。
现在在rails指南中(大概是4个),它没有提到在他们的例子中这样做。
http://guides.rubyonrails.org/association_basics.html#the-has-and-belongs-to-many-association
这仍然是一项要求吗?我已经完成了它似乎工作正常吗?
答案 0 :(得分:2)
我相信Rails 4如果你使用rails g migration CreateJoinTableCustomerProduct customer product
它默认会创建没有主键的连接表,因为这是首选的样式。您不需要像这样的连接表中的主键。