我在简历和教育之间有多对多的关系,这允许相同的教育条目出现在多份简历上。在简历上显示教育时,我希望为该特定简历订购教育。为此,我设置了一个连接表 Educations_Resumes,其中订单信息作为属性。
但是,当我尝试类似 resume.educations 时,我收到以下错误:
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
模型设置为:
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
任何有关如何正确订购 resume.educations 的建议将不胜感激