我正在尝试做一些我认为很简单但似乎并非如此的事情。
我的项目模型有很多职位空缺。
class Project < ActiveRecord::Base
has_many :vacancies, :dependent => :destroy
end
我要获得所有至少有1个空缺的项目。我尝试过这样的事情:
Project.joins(:vacancies).where('count(vacancies) > 0')
但它说
SQLite3::SQLException: no such column: vacancies: SELECT "projects".* FROM "projects" INNER JOIN "vacancies" ON "vacancies"."project_id" = "projects"."id" WHERE ("projects"."deleted_at" IS NULL) AND (count(vacancies) > 0)
。