Reputation: 2184
I have a large database of information. They are mostly patients. Some of them have email addresses and some of them don't. I can pull an additional email address by simply running
Patient.last.email
However I only want to see the patients who do not have email addresses. (I think its about half of the ones that I have)
I've tried both these below, but not having the best of luck.
Patient.includes(:email).where('email = ?', 'nil')
Patient.includes(:email).where('email = ?' 'nil').references(:email)
Would anyone know what I'm doing wrong?
Upvotes: 0
Views: 36
Reputation: 330
Simple then.
Patient.where(email: nil)
Should get you your result.
Upvotes: 1