title: How to filter records from association
body: <p>How to get records from association? I have 4 jobs in my jobs table.How to filter all jobs with resource_type_id=2. From the below records here for eg (I want to get job id with 2 and 3 as result).</p>
  
  <p>Here is my association</p>
  
  <pre><code>class Job &lt; ActiveRecord::Base   
    has_many :jobs_resources   
    has_many :resource_type, through: :jobs_resources, dependent: :destroy   
  end
  
  class ResourceType &lt; ActiveRecord::Base   
    has_many :jobs_resources   
    has_many :jobs, through: :jobs_resources, dependent: :destroy end
  
  class JobsResource &lt; ActiveRecord::Base   
    belongs_to :job   
    belongs_to :resource_type 
  end
  </code></pre>
  
  <p>This is my how resources_type table is saved:</p>
  
  <p><a href="https://i.stack.imgur.com/MKFvg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MKFvg.png" alt="enter image description here"></a></p>
  
  <p>This is my JobsResource table records:</p>
  
  <p><a href="https://i.stack.imgur.com/Svuvs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Svuvs.png" alt="enter image description here"></a></p>