I'd like an ActiveRecord query that lets me return all the users that have zero email_sessions. Here're my models:
class User
has_many :email_sessions
end
class EmailSession
belongs_to :user
end
It would be pretty straight-forward to do this after the AR query, like so:
User.all.reject {|u| u.email_sessions.count > 0}
But it gets to be pretty computationally-expensive as it steps through every user to check the count. I also want to use arel to chain together different where statements after this.
Any ActiveRecord sooper geniuses want to take a crack at this? :-)