title: How do I add migration with multiple references to the same model in one table? Ruby/Rails
body: <p>How do I create a migration with two fields that reference the same table? I have tables A, and image. A.image1_id will reference image, and A.image2_id will reference image also. There are only 2 images, not many. If I use</p>
  
  <pre><code>class AddFields &lt; ActiveRecord::Migration
     def change
      change_table(:ticket) do |t|
          t.references :image1_id
          t.references :image2_id
      end
    end
  end
  </code></pre>
  
  <p>I don't think that will work because it will add another _id to the end and probably won't know to use the 'image' model. I also thought about</p>
  
  <pre><code>change_table(:ticket) do |t|
      t.references :image
  </code></pre>
  
  <p>But then how do I add two of those? I also thought about adding </p>
  
  <pre><code>create_table :images do |t|
    t.belongs_to :ticket
    t.string :file
  </code></pre>
  
  <p>But I only want 2, not many, and this doesn't appear to allow getting to the image from the ticket, like <code>ticket.image1</code> or <code>ticket.image2</code>. </p>
  
  <p>According to this documentation <a href="http://apidock.com/rails/v3.2.8/ActiveRecord/ConnectionAdapters/SchemaStatements/change_table" rel="noreferrer">http://apidock.com/rails/v3.2.8/ActiveRecord/ConnectionAdapters/SchemaStatements/change_table</a> which is all I could find, t.references doesn't appear to take any arguments either. </p>
  
  <pre><code>change_table(:suppliers) do |t|
    t.references :company
  end
  </code></pre>