开发者

Ordering through has_one association

开发者 https://www.devze.com 2023-03-31 01:07 出处:网络
I开发者_运维百科 have two types of records: Person and PersonDetail. Each Person has_one PersonDetail.

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

精彩评论

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