title: has_many :through : How do you access join table attributes?
body: <p>I have the following models in Rails 4 with a simple has_many :through association:</p>
  
  <pre><code>class Model &lt; ActiveRecord::Base
    has_many :model_options
    has_many :options, through: :model_options
  end
  
  class Option &lt; ActiveRecord::Base
    has_many :model_options
    has_many :models, through: :model_options
  end
  
  class ModelOption &lt; ActiveRecord::Base
    belongs_to :model
    belongs_to :option
  end
  </code></pre>
  
  <p>I want to be able to iterate over a Model instance's Options: </p>
  
  <pre><code>  model = Model.find.first
    model.options.each {}
  </code></pre>
  
  <p>and access the attributes on the join table.</p>
  
  <p>In Rails 3 you could do this:</p>
  
  <pre><code>class Model &lt; ActiveRecord::Base
    has_many :model_options
    has_many :options, through: :model_options , select: 'options.*, model_options.*'
  end
  </code></pre>
  
  <p>But select: is deprecated and this produces a deprecation warning.</p>
  
  <p>That said, the SQL generated contains the link table data:</p>
  
  <pre><code>SELECT options.*, model_options.* FROM "options"
  INNER JOIN "model_options" ON "options"."id" = "model_options"."option_id"
  WHERE "model_options"."model_id" = $1 ORDER BY "options".name ASC  [["model_id", 1]]
  </code></pre>
  
  <p>But the collection returned by AR from model.options removes the link table data.</p>
  
  <p>To remove the deprecations warning in Rails 4, and still produce the same SQL, I did this:</p>
  
  <pre><code>class Model &lt; ActiveRecord::Base
    has_many :model_options
    has_many :options, -&gt; { select('options.*, model_options.*') }, through: :model_options
  end
  </code></pre>
  
  <p>So, the query is correct, but I am struggling to find the correct way to access the link table data.</p>
  
  <p>I have tried various ways:</p>
  
  <pre><code> model options
   model.options.joins(:model_options)
   model.options.select('options.*, model_options.*')
   model.model_options.joins(:option)
   ...
  </code></pre>
  
  <p>None include the join table data.</p>
  
  <p>Thanks.</p>