Forum: Ruby on Rails Naming confusion

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Pete Callaway (Guest)
on 2006-02-11 18:08
(Received via mailing list)

I have a database setup with 2 tables and a simple one-to-many
relationship where
article_categories have many articles.

In the models ruby has created for me, I've added "belongs_to
:article_category" to the Article class and "has_many :articles" to
the ArticleCategory class.

Everything seems fine until I try to reference the category from the
article. In my view for example,  I have
"", but this throws an error..

You have a nil object when you didn't expect it!
The error occured while evaluating

The referential integrity is fine. I imagine having an categories
table as opposed to article_categories may help, but I have other
types of categories in my database.

Any pointers would be a great help.

Thanks in advance,
Pete Callaway (Guest)
on 2006-02-11 18:33
(Received via mailing list)
> "", but this throws an error..
> Any pointers would be a great help.
I managed to solve the problem after a little more poking.

I'd incorrectly named the article_category_id column in the article
table as category_id. All works fine now.

This topic is locked and can not be replied to.