1

In development on sqlite this works a charm:

@human = Human.joins(:human_logins).group("human_logins.human_id").order("count(human_logins.human_id) ASC")

Though, in production on Heroku and using PG, it crashes and I get the following error:

 ActionView::Template::Error (PG::GroupingError: ERROR:  column "humans.id" must appear in the GROUP BY clause or be used in an aggregate function

Guessing it's just a compatibility problem, any insight on how I can alter this so that it works nicely in production would be awesome.

John Long
  • 257
  • 2
  • 14
  • Yes @muistooshort, I'm a beginner if I'm honest and i'm trying to comprehend how I would adapt the posted fixes to my scenario :( – John Long Apr 20 '15 at 18:43
  • @muistooshort Will migrate soon. I'm trying to simply count by association. Human is my model, it has_many human_logins and I want to order humans by the count of their human_logins association – John Long Apr 20 '15 at 19:47

0 Answers0