开发者

Ordering through has_one association

I开发者_运维百科 have two types of records: Person and PersonDetail.

Each Person has_one PersonDetail.

I would like to order People based on a field that is in PersonDetail. How do I do that?


Try this:

Person.joins(:person_detail).order('person_details.detail_field')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜