title: Rails has_many chain
body: <p>So I have a table structure below:</p>
  
  <p><strong>Plane</strong></p>
  
  <ul>
  <li>plane_id</li>
  <li>plane_info</li>
  </ul>
  
  <p><strong>Seating</strong></p>
  
  <ul>
  <li>seating_id</li>
  <li>seating_info</li>
  </ul>
  
  <p><strong>PlaneSeating</strong></p>
  
  <ul>
  <li>plane_seating_id</li>
  <li>plane_id</li>
  <li>seating_id</li>
  </ul>
  
  <p><strong>PlaneSeatingNote</strong></p>
  
  <ul>
  <li>plane_seating_note_id</li>
  <li>plane_seating_id</li>
  <li>note_id</li>
  </ul>
  
  <p><strong>Note</strong></p>
  
  <ul>
  <li>note_id</li>
  <li>note_info</li>
  </ul>
  
  <p>This gives me a third-normal DB, but I need to set the model relations up.</p>
  
  <p>I currently have:</p>
  
  <pre><code>class Plane &lt; ActiveRecord::Base
  
    has_many :plane_seatings, dependent: :destroy
    has_many :seatings, through: :plane_seatings
  
  end
  
  class Seatings &lt; ActiveRecord::Base
  
    has_many :plane_seatings, dependent: :destroy
    has_many :planes, through: :plane_seatings
  
  end
  
  class PlaneSeating &lt; ActiveRecord::Base
  
    belongs_to :plane
    belongs_to :seating
    has_many :plane_seating_notes, dependent: :destroy
    has_many :notes, through: :plane_seating_notes
  
  end
  
  class PlaneSeatingNote &lt; ActiveRecord::Base
  
    belongs_to :plane_seating
    has_one :note
  
  end
  
  class Note &lt; ActiveRecord::Base
  end
  </code></pre>
  
  <p>Now, this will give me the ability to say <code>Plane.all.first.plan_seatings.first.notes</code> and get the notes I believe. However, I'd like to be able to say <code>Plane.all.first.seatings.notes</code> and get the notes associated with that plane given that seating. </p>
  
  <p>My thought is there should be a way to say, in Plane:</p>
  
  <pre><code>has_many :seatings, through: plane_seating, has_many :notes, through: plane_seating
  </code></pre>
  
  <p>or some other chaining magic to get a seating with some notes that only apply to that plane and seating combo. a :with, if you will. But I can't think of any syntax that would give me that. Anyone know?</p>