has_and_belongs_to_many 방법 사용 주의

601 단어 long
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)

 
 
원래 잘못된 이 유 는 내 가 만 든 중간 표:artspages 에 id 필드 가 하나 더 생 겼 습 니 다.
수정 방법:
 create_table :arts_pages , :id => false do |t|

좋은 웹페이지 즐겨찾기