How to convert an ActiveRecord_AssociationRelation into an array in ActiveRecord?
<p>How can I convert an <code>ActiveRecord_AssociationRelation</code> into an array of Rails model instances?</p>

<p>I have code that is in an <code>after_save</code> hook like this:</p>

<pre><code>class Like &lt; ApplicationRecord
  belongs_to :likee, class_name: 'User', foreign_key: 'likee_id'
  belongs_to :liker, class_name: 'User', foreign_key: 'liker_id'

  after_save :mutual_like?

  private

  def mutual_like?
    if liker.likes.where(likee: liker) // returns collection proxy but I want to return an array of model instances so that I can create another model

    end
  end
end
</code></pre>

<p>Is there a way to return an array of instances instead?</p>

<p>Table for reference:</p>

<pre><code>  create_table "likes", force: :cascade do |t|
    t.integer  "liker_id",      null: false
    t.integer  "likee_id",      null: false
    ...
  end
</code></pre>

<p>I believe the problem is that Rails is not associating the models based on the foreign key of likee_id / liker_id. </p>