Primary key is not allowed in a has_and_belongs_to_many join table (arts_pages).
由于项目需要使用了has_and_belongs_to_many,在执行代码:
n = Art.find 22
n.pages << Page.new
时出现下面错误:
Primary key is not allowed in a has_and_belongs_to_many join table (arts_pages)
原来错误的原因是在我创建的中间表:arts_pages中多了一个id字段
修改办法:
create_table :arts_pages , :id => false do |t|