AR: Many models on one table

Let's say I have this table:

CREATE TABLE people (   id serial unique,   person_type varchar(32) check type in ('staff', 'customer'),   name varchar(256) );

Now, since I store staff and customers in the same table I'd like to have different models for them, too, like:

class Friend < ActiveRecord::Base set_table_name 'people' end class Staff < ActiveRecord::Base set_table_name 'people' end

I understand that I can use before_insert and before_update to force a person_type to be 'staff' or 'customer'. But is there also any way to add a condition (person_type='staff') on all the other methods especially those who will use SQL SELECT, like find...

Thanks, martin

Sounds like you reinventing STI (single table inheritance)


Yes, that will do. Thanks!