One table, two models

so i have a people table, and a person has a persontype. the person
types are customer, and employee. I would like to make them into two
models, where i can call Employee.new(:name => ‘chris’) and it would
make a person with the name chris and the persontype of employee, and be
able to do the same thing for Customer. is this possible while still
using only the one person table?

As far as I know, no.

But you can use single table inheritance to handle this

create_table :people do |t|
column :first_name, :string
column :last_name, :string
column :type, :string
end

class Person < ActiveRecord::Base
end

class Employee < Person
end

class Customer < Person
end

p = Person.create :first_name => “Homer”, :last_name => “Simpson”,
:type
=> “Customer”
p.class
=> Customer

or just do

c = Customer.create :first_name => “Homer”, :last_name => "Simpson

Notes:

The “type” column is absolutely necessary. It stores the class name as a
string.

All columns used in all models must be in the person table. You may end
up
with lots of null columns, but that’s usually ok.