The best decision (as Mr. Yoshiji commented)
@starters = @users.includes(:results).where(results: { id: nil })
This will fulfill the same request as in my second solution.
Another SQL solution
You can use LEFT OUTER JOIN . Thus, you will always have all the results from the "left" table ( users ), but you will also have the corresponding entries for the "right" ( results ) table, although not, which will leave you with empty fields that you can check.
@starters = @users.joins("LEFT OUTER JOIN results ON results.user_id = users.id").where("results.user_id IS NULL")
In your case, replace users with the name of your "custom" model.
Another Ruby Solution
@starters = @users.select { |u| !!u.results }
Here !! will result in conversion to a boolean, if there are no results , u.results will return [] (empty array). And !![] is true .
source share