0
votes

When executing User.group(:type).count I received the following error:

ERROR: column "users.created_at" must appear in the GROUP BY clause or be used in an aggregate function

What is causing this?

1

1 Answers

0
votes

I had used a default scope to order the User. When I changed the query to User.unscope(:order).group(:type).count it worked properly.

This pushes me to agree with people who warn against using any default scopes.