2015-10-17 54 views
1

我有3個表格:articles,peopleperson_mentions在其他表格列中訂購記錄

Article型號has_many :people, through: person_mentions等等。

person_mentions表I中,我有3欄article_id,person_idmention_ordermention_order是一個整數。

我需要找到所有的人,誰的文章,並責令其按mention_order提到的,但是當我運行

@article.people.order(mention_order: :asc) 

我得到一個錯誤

列people.mention_order不存在

所以,我需要從people查詢表mention_orderperson_mentions在裏面。

感謝您的幫助!

回答

3

你能嘗試:

@article.people.order("person_mentions.mention_order asc")