title: Rails 4 Migration | Add Table with Reference
body: <p>I am attempting to create a <code>Collaboration</code> table in my Rails 4 project, but I've run into an issue.  I wish it to belong_to a single user, the collaborator.</p>
  
  <p>I ran the following command to generate the model and the migration, which I've also copied below.</p>
  
  <pre><code>rails generate model Collaboration project:references collaborator:references accepted:boolean
  </code></pre>
  
  <p>Migration:</p>
  
  <pre><code>class CreateCollaborations &lt; ActiveRecord::Migration
      def change
          create_table :collaborations do |t|
              t.references :project, index: true, foreign_key: true
              t.references :collaborator, index: true, foreign_key: true
              t.boolean :accepted
  
              t.timestamps null: false
          end
      end
  end
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>class Collaboration &lt; ActiveRecord::Base
      belongs_to :project
      belongs_to :collaborator, class_name: 'User'
  end
  </code></pre>
  
  <p>I updated the Collaboration model to include <code>, class_name: 'User'</code> as shown above.  Similarly, I updated the existing <code>Strategy</code> model to include a <code>has_many :collaborations</code> </p>
  
  <pre><code>class Project &lt; ActiveRecord::Base
      has_many :collaborations
  end
  </code></pre>
  
  <p>When I run <code>rake db:migrate</code>, I get the following error reported.</p>
  
  <pre><code>rake aborted!
  StandardError: An error has occurred, this and all later migrations canceled:
  
  PG::UndefinedTable: ERROR:  relation "collaborators" does not exist
  </code></pre>
  
  <p>I'm a bit puzzled as to wy this is happening.  <strong>Any assistance would be greatly appreciated!</strong>  Thank you. :)</p>
  
  <p>EDIT:</p>
  
  <p>Adding code for my <code>User</code> model as well.</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
      authenticates_with_sorcery!
  
      has_many :projects
      has_many :collaborations
  end
  </code></pre>
  
  <p>I edited out validations for fields such as password, email, etc to try to remove clutter.</p>