Archives: 2010 March
Polymorphic Single Table Inheritance (STI)
March 30th, 2010, Comments Off
Migration:
create_table :addresses do |t|
….
t.references :addressable, :polymorphic => true
t.string :type
t.timestamps
end
Address Models:
class Address < ActiveRecord::Base
belongs_to :addressable, :polymorphic => true
end
class InvoiceAddress < [...]