I'd like to select posts that have one or more comments using Rails 3 and a single query.
I'm 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've googled this and similar approaches, group by, etc with no luck. Any help will be appreciated.