title: Can I join a table with no association? (rails/sql)
body: <p>I have these 3 classes:   </p>
  
  <pre><code>class Factory &lt; ActiveRecord::Base
    has_many :machines
  end
  
  class Machine &lt; ActiveRecord::Base
    belongs_to :factory, inverse_of: :machines
    has_many :assembly_jobs, inverse_of: :machines
  end
  
  class AssemblyJob &lt; ActiveRecord::Base
    belongs_to :machines, inverse_of: :assembly_jobs
  end
  </code></pre>
  
  <p>Schema</p>
  
  <pre><code>Factories
  - id
  
  Machines
  - factory_id
  
  AssemblyJobs
  - machine_id
  - start_time
  - error_time
  - finish_time
  </code></pre>
  
  <p>I want to be write a scope in <code>factory.rb</code> to return any factories that have any machines with assembly jobs with error_time. Is this possible or do  I need to add a factory_id column to assembly job and create a belongs_to association?</p>