Problem with relations

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.


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


Hi Amador,

Looking at the application code you attached, your migration has the
wrong code in db/migrate/

Basically, in the book (, 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.


Thanks, it works. Now I can continue with the book.