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.
549fedd6c11bd168c98a5cd20c5c8314?d=identicon&s=25 Pete Callaway (Guest)
on 2006-02-11 17: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,
60d913332ed1864af9e740751ca5bfb9?d=identicon&s=25 Pete Callaway (Guest)
on 2006-02-11 17: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.