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')
精彩评论