我有一个Book模型,该模型具有很多选票,我需要按多数选票将选票和顺序分组。
Book.where(status: :inactive, release: :coming_soon).joins(:votes).group("votes.book_id").order("count(votes.book_id) desc")
我收到此错误:PG::GroupingError: ERROR: column "books.id" must appear in the GROUP BY clause or be used in an aggregate function. I don't know to to solve it