title: rails creating relationships between 2 existing models
body: <p>I have 2 models:</p>
  
  <pre><code>Account
  Profile
  </code></pre>
  
  <p>creating these models created 2 tables in the database:</p>
  
  <pre><code>accounts
  profiles
  </code></pre>
  
  <p>now I want to add a relationship:</p>
  
  <ul>
  <li>each account can have many profiles</li>
  <li>each profile belongs to one account</li>
  </ul>
  
  <p>I ran the following command:</p>
  
  <pre><code>rails g migration AddAccountToProfiles account:references
  </code></pre>
  
  <p>which created the following migration:</p>
  
  <pre><code>class AddAccountToProfiles &lt; ActiveRecord::Migration
    def change
      add_reference :profiles, :account, index: true, foreign_key: true
    end
  end
  </code></pre>
  
  <p>now I'm a little confused:</p>
  
  <p>why does the migration say <code>:profiles</code> and <code>:account</code>? Shouldn't it be <code>:accounts</code> (plural)?</p>
  
  <p>also, after (or before) creating this migration, I have to add <code>belongs_to</code> and <code>has_many</code> in the appropriate model class right?</p>
  
  <p>as a side question, is there a way to add <code>belongs_to</code> and <code>has_many</code> in the models, and from that information have rails generate the appropriate migration without me manually creating a migration with the <code>'rails g migration ...'</code> command?</p>