Rails: How to sort many-to-many relation

前端 未结 3 637
攒了一身酷
攒了一身酷 2021-01-29 04:10

I have a many-to-many relationship between a model User and Picture. These are linked by a join table called Picturization.

If I obtain a list of users of a single pict

3条回答
  •  有刺的猬
    2021-01-29 05:02

    You can specify the table name in the order method/clause:

    picture.users.order("picturizations.created_at DESC")
    

提交回复
热议问题