I’m looking for a way on the Rails console to find users in the system that don’t have tickets associated with them.
I was able to create a query on the database to do this, but I’d prefer not to access the db directly.
I was able to create a respective query on the database, but I’d prefere to prevent accessing the db directtly.
The query looks like this:
SELECT t0.id,t0.email FROM users t0 LEFT JOIN tickets t1 ON t1.customer_id = t0.id GROUP BY t0.email,t0.id having COUNT(t1.id) = 0;
So how do I get the same result on the console?
Thanks and best regards
Kay