How to reflect in the database a new belongs_to and has_many relationship in Ruby on Rails

Posted by Ken I. on Stack Overflow See other posts from Stack Overflow or by Ken I.
Published on 2011-01-06T20:44:34Z Indexed on 2011/01/06 20:53 UTC
Read the original article Hit count: 498

I am new to rails (usually a python guy) and have just been trying to build a simple task manager application for fun. I am using Devise for authentication and have a single Task object I am trying to relate to a user. I have added the following to the Task model:

class Task < ActiveRecord::Base
    belongs_to :user
end

and I have added the following in my User model for Devise:

class User < ActiveRecord::Base
   has_many :dreams

   <<normal Devise stuff>>
end

Whenever I added this information I then ran: rake db:migrate. It then gave me an error that the database field did not exist for user_id when I tried to do anything with it.

I am sure it is something rather simple that I am missing. Thanks for the help.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby