프로젝트 목록이 있고 작업이있는 프로젝트 만 표시하려고합니다. has_many 관계에 count를 가진 조건을 사용할 수 있습니까?has_many 릴레이션에 count가있는 조건을 사용할 수 있습니까?
# get my project list
Project.includes(:tasks).where(...)
class Project < ActiveRecord::Base
has_many :tasks
class Task < ActiveRecord::Base
belongs_to :project
현재 루프를 통해이 작업을 수행하고 있지만 이것이 올바른 방법이라고 생각하지 않습니다.
내가 [여기]를 비슷한 질문을 한 (http://stackoverflow.com/questions/8227557/activerecord-find-categories-which-contain-at-least-one-item). 그것이 당신을 도울 수 있기를 바랍니다. – ZelluX