0
동일한 이력서를 여러 개의 이력서에 표시 할 수 있도록하는 이력서와 교육간에 다 대다 관계가 있습니다. 이력서에 교육을 표시 할 때 해당 이력서에 대한 교육을 주문해야합니다. 이렇게하기 위해 주문 정보 인 프로덕션으로 조인 테이블 인 Educations_Resumes를 설정합니다. 나는 다음과 같은 오류 얻을 몇 가지 같은 resume.educations하려고 할 때다 대다 관계에서 조인 테이블 특성을 기준으로 정렬
: 제대로 resume.educations를 주문하는 방법에 대한
class Resume < ActiveRecord::Base
has_many :educations_resumes
has_many :educations, :through => :educations_resumes,
:order => 'educations_resumes.order'
end
class EducationsResume < ActiveRecord::Base
belongs_to :resume
belongs_to :education
end
class Education < ActiveRecord::Base
has_many :educations_resumes
has_many :resumes, :through => :educations_resumes
end
어떤 제안 :
ActiveRecord::StatementInvalid: SQLite3::SQLException: near "order": syntax error:
SELECT "educations".* FROM "educations" INNER JOIN "educations_resumes" ON
"educations"."id" = "educations_resumes"."education_id" WHERE
"educations_resumes"."resume_id" = 2 ORDER BY educations_resumes.order
모델을 설정 등은 크게 환영합니다
감사 :
이것은 당신이 같은으로 작성해야 빈 마이그레이션 파일을 줄 것이다! 나는 그런 것을 간과했다고 믿을 수 없다. – CodyAustun
괜찮습니다. 정말 도움이 될 수있어서 정말 기쁩니다. 처음에는 미끄러운 대답에 대해 유감스럽게 생각합니다. 더 읽기를 배워야합니다. 그러나 열 이름을 '주문'이라고 명명 한 사실로 인해 코드 :) 행운을 빌어 요! – Zippie