I would like to select posts containing one or more comments using Rails 3 and one query.
I am trying something like this:
Post.includes(:comments).where('count(comments.id)>0')
However, I get this error:
ActiveRecord::StatementInvalid: PGError: ERROR: aggregates not allowed in WHERE clause
I was looking for this and similar approaches, group, etc., no luck. Any help would be appreciated.
source share