【发布时间】:2015-10-17 20:35:00
【问题描述】:
我有 3 张桌子:articles、people 和 person_mentions。
Article 型号has_many :people, through: person_mentions 等等。
在person_mentions 表中,我有3 列article_id、person_id 和mention_order。 mention_order 是一个整数。
我需要找到文章中提到的所有人并通过mention_order订购他们,但是当我运行时
@article.people.order(mention_order: :asc)
我收到一个错误
列 people.mention_order 不存在
所以,我需要从people 表中查询mention_order 来自person_mentions。
感谢您的帮助!
【问题讨论】:
标签: ruby-on-rails postgresql rails-activerecord