lundi 20 avril 2015

Rails order by count on association

I have 2 models. Gif, GifStatistic

gif has_many :gif_statistics

GifStatistics has column called state. It can be either like or dislike

What i want to achieve is to query gifs, but order them in highest count of likes

Something like(Pseudo code)


How do i achieve this?

Aucun commentaire:

Enregistrer un commentaire