0
allcomments = @comments.reverse_order
allcomments = allcomments.group("owner_id,owner_type")
我想實現類似這樣的事情,但是當rails執行查詢時。它會:Rails集團之前的訂單
Comment Load (0.5ms) SELECT `comments`.* FROM `comments` ORDER BY `comments`.`id` DESC
Comment Load (3.5ms) SELECT `comments`.* FROM `comments` GROUP BY owner_id,owner_type ORDER BY `comments`.`id` DESC
基本上,我想要反序的評論,所以當他們組,它會列出最新評論,而不是每個用戶的第一條評論。
這不工作; *訂單*仍然移至*組*之後 – Qqwy