Assume that a tree has many apples and an apple belongs to only one tree.
I am trying to run a query that returns me trees that have greater than 2 apples. I am stuck on this:
Tree.joins(:apples).where('count(tree.apples) >= 2')
(pry) output error: #<ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: syntax error at or near "tree"
I don't think I can do tree.apples since apples isn't an actual column on tree but an association.