Jeanro Krupa
class Account < ApplicationRecord has_many :jobs scope :with_a_job, -> { where.associated(:jobs) } scope :without_a_job, -> { where.missing(:jobs)} end
SELECT "accounts".* FROM "accounts" LEFT OUTER JOIN "jobs" ON "jobs"."account_id" = "accounts"."id" WHERE "jobs"."id" IS NULL
SELECT "accounts".* FROM "accounts" INNER JOIN "jobs" ON "jobs"."account_id" = "accounts"."id" WHERE "jobs"."id" IS NOT NULL