title: Rails 5: ActiveRecord collection index_by
body: <p>Upgraded app to Rails 5 using the index method. The issue is that it is not incrementing to the next ActiveRecord collection record. The below code below use to work in Rails 4.0. Tried with index_by.</p>
  
  <pre><code>def next_question
    index = campaign.quiz_questions.index self
    campaign.quiz_questions[index + 1]
  end
  </code></pre>
  
  <p>Debugger</p>
  
  <pre><code>(byebug) campaign.quiz_questions.index
  *** NoMethodError Exception: undefined method `index' for #&lt;QuizQuestion::ActiveRecord_Associations_CollectionProxy:0x007f80012d71b0&gt;
  Did you mean?  index_by
  </code></pre>
  
  <p>Using index_by</p>
  
  <pre><code>(byebug) index = campaign.quiz_questions.index_by
  #&lt;Enumerator: #&lt;ActiveRecord::Associations::CollectionProxy [#&lt;QuizQuestion id: 113, campaign_id: 492, message: "Where did Hullabalooza's freak show manager send H...", created_at: "2016-07-20 20:50:32", updated_at: "2016-07-20 20:50:32"&gt;]&gt;:index_by&gt;
  </code></pre>
  
  <p>Index + 1</p>
  
  <pre><code>(byebug) index + 1
  *** NoMethodError Exception: undefined method `+' for #&lt;Enumerator:0x007fc4db445960&gt;
  
  nil
  </code></pre>