index: true vs foreign_key: true (Rails) : <p>Following a guide, I ran the following command:</p>

<pre><code>rails g migration CreateSnippetsUsers snippet:belongs_to user:belongs_to
</code></pre>

<p>This created the following migration:</p>

<pre><code>class CreateSnippetsUsers &lt; ActiveRecord::Migration[5.0]
  def change
    create_table :snippets_users do |t|
      t.belongs_to :snippet, foreign_key: true
      t.belongs_to :user, foreign_key: true
    end
  end
end
</code></pre>

<p>In the past I've seen the same thing, but with <code>index: true</code> instead of <code>foreign_key: true</code>. What's the difference between the two?</p>
