0
我在简历和教育之间建立了多对多关系,允许在多份简历中显示相同的教育条目。在简历上显示教育信息时,我希望为特定简历订购教育信息。为此,我设置了一个连接表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任何建议将不胜感激
谢谢!我无法相信我忽略了这样的事情。 – CodyAustun 2013-03-19 03:06:55
没问题,我真的很高兴能够帮助你,并且首先对一些敏感的答案感到抱歉,我必须学会更好地阅读,但事实上,当你看到你的名字时,你命名列'order'有点让我无法理解代码:)祝你好运! – Zippie 2013-03-19 03:09:55