I\'m trying to do something that I thought it would be simple but it seems not to be.
I have a project model that has many vacancies.
class Project &
In Rails 4+, you can also use includes or eager_load to get the same answer:
Project.includes(:vacancies).references(:vacancies). where.not(vacancies: {id: nil}) Project.eager_load(:vacancies).where.not(vacancies: {id: nil})