title: Adding a Reference Column to an Existing Table During Association in Rails3.2.9
body: <p>I have two models in my rails application. One is User that I have generated through with Devise and another one is Links. Now Initially There was only the Link model in my application. So I had two columns in my model Link namely <strong>"id"</strong> and <strong>"link"</strong> . Now my requirements have changed and I need implement a User model. A user in my application has one or many links. So added the line <code>has_many :links</code> to my <strong>"user.rb"</strong> and <code>belongs_to :users</code> to my <strong>"link.rb"</strong> file.</p>
  
  <p>And I generated a migration like:</p>
  
  <pre><code>rails generate migration add_user_id_to_link user:references
  </code></pre>
  
  <p>That is, I'm generating a migration file to modify my existing table <strong>"links"</strong> and add a reference column <strong>"user_id"</strong> to the table.</p>
  
  <p>But it's giving an error when running <code>rake db:migrate</code>. Then I ran the command:</p>
  
  <pre><code>rails genearate migration add_user_id_to_links user_id:integer
  </code></pre>
  
  <p>But it's giving a command not found error. Now the question is how do I achieve this??</p>
  
  <p>Thanks in advance... </p>