Forum: Ruby on Rails Model extends and belongs_to another model - problem

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.
6ec1e89eef5ce09fbfa56be5b6dd17b5?d=identicon&s=25 Adam Bloom (admanb)
on 2006-04-14 17:58
I have a model, categories, and another model, subcategories. In my
current code these have no connection except for the fact that
categories has_many subcategories and a subcategory belongs_to a
category. But by necessity, I need to change it so Subcategory extends
Category; so that I can search both models with one command.

I was hoping it would be as simple as changing Subcategory <
ActiveRecord::Base to Subcategory < Category, but no such luck. Now I
get the error:

no such column "category_id" in categories

when the page tries to run:

<% for subcategory in category %>

What am I missing about inheritance? AWD has very little on the subject.


6ec1e89eef5ce09fbfa56be5b6dd17b5?d=identicon&s=25 Adam Bloom (admanb)
on 2006-04-15 02:19
Any thoughts?

This topic is locked and can not be replied to.