1

This problem appeared when I changed Sqlite3 to PostgreSQL. Seems like I cannot use group method when I use postgres.

> Post.group(:user_id).all

Post Load (74.2ms)  SELECT "posts".* FROM "posts" GROUP BY user_id
PG::Error: ERROR:  column "posts.id" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: SELECT "posts".* FROM "posts"  GROUP BY user_id

Is it possible to use equivalent query to avoid hardcoded SQL and use benefit of elegant AR methods?

0

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.