Reputation: 8597
I'm still fairly new to Ruby on Rails and I'm working with associations, such as if a table has_many :facts, or belongs_to :list,
do we deal with users as well? for Users model:
has_many :lists
and then the list model should have
belongs_to :user
Now does this mean I need to create a new column in the table? Right now I only have email and password_digest. Do I need to add a new migration to add a new column list_id
. I already did rake db:migrate
. Can I just simply add a column in the migration file?
Thanks
Upvotes: 1
Views: 483
Reputation: 10218
Yes, you must create a new column and if you already run the migration you must create a new one.
However, it's the list that must have the user_id
.
Upvotes: 2