title: Rails Association Tertiary has_many belongs_to
body: <p>I'm struggling to find the solution to this basic problem. Google terms would also be appreciated.</p>
  
  <p>I have three tables: Shoes, Socks and Traits</p>
  
  <p>A Shoe has many socks. Socks belongs to a Shoe. A sock has many traits. A trait belongs to a sock.</p>
  
  <p>In my show view of Shoes, for a given shoe of id:x I want to display the socks that belong to it, and the traits that belong to those socks.</p>
  
  <pre><code>class ShoesController
    def show
      @shoe = Shoe.find(params[:id])
      @socks= @shoe.socks
    end
  </code></pre>
  
  <p>Using this code I can shoe the socks that belong to the shoe with id:x. But how do I find the traits that belong to the socks that belong to the shoe with id:x?
  I think the solution is something like:</p>
  
  <pre><code>@sock = Sock________
  @trait = @sock.traits
  </code></pre>
  
  <p>But I don't know how to run the search on this piece of data</p>