Forum: Ruby on Rails Single Table inheritance

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.
Vikrant Rathore (Guest)
on 2006-01-05 08:32
(Received via mailing list)
Hi Everyone,

Just been thinking and working on some problem in Supply Chain and came
across a situation. This is like this using single table inheritance I
have a single table called company and the active record are like this:

class Company < ActiveRecord::Base

class Vendor < Company
class Customer < Company
class Office < Company

Then there is another class called Region which is

class Region < ActiveRecord::Base

now there is many to many relationship between Vendor and Region and
there is many to many relationship between Office < Region and also in

Now can I use vendor_id , customer_id and office_id as foreign key or
can only use company_id since the table for company is only 1 with
primary key id.

Thanks for help
This topic is locked and can not be replied to.