title: Rails Active Records : foreign_key vs references
body: <p>This is my code</p>
  
  <pre><code>class CreatePosts &lt; ActiveRecord::Migration[5.1]
    def change
      create_table :posts, id: :uuid do |t|
        t.string :name
  
        t.references :user, type: :uuid
        t.references :user, type: :uuid, foreign_key: true    
  
        t.timestamps
      end
    end
  end
  </code></pre>
  
  <p>I am confused what is the difference b/w these line.Both lines of code are working fine to accomplish reference between table . </p>
  
  <pre><code>t.references :user, type: :uuid
  t.references :user, type: :uuid, foreign_key: true   #what this line is doing 
  </code></pre>
  
  <p>Can anybody explain me when to use <strong>foreign_key</strong>  or <strong>not</strong> . </p>
  
  <p>I find the similar things while searching these</p>
  
  <pre><code>t.references :makers, foreign_key: { to_table: :office }
  </code></pre>
  
  <p>In above code <strong>foreign_key</strong> is not true. It referencing to some table. why is it so.</p>