Hi guys, I’m following the Beginning Rails 3 Book, I’ve problems with the many to many relationship between Article-Category, when I try to create or show a article.
Please help me, I’m new with Rails.
Regards,
blog.rar (136 KB)
Hi guys, I’m following the Beginning Rails 3 Book, I’ve problems with the many to many relationship between Article-Category, when I try to create or show a article.
Please help me, I’m new with Rails.
Regards,
blog.rar (136 KB)
And has your articles_categories table got a column category_id? If you think it has then how do you know? If you still think it has show us db/schema.rb
Colin
Hi Amador,
Looking at the application code you attached, your migration has the wrong code in db/migrate/ 20101208225837_create_articles_categories.rb.
Basically, in the book (https://gist.github.com/324042), we use:
t.references :category
and not
t.references :categories
What you can do to fix this is to rollback your database using: 'rake db:rollback', until you're back before this particular migration. Update the file, and then run 'rake db:migrate' and you should be good to go.
I hope this fixes your problem.
Cheers,
Thanks, it works. Now I can continue with the book.
Regards,