Plugins - Inherits From
Add to favoritesImplements class table inheritance in ActiveRecord. A quick example:
create_table "books", :force => true do |t|
t.column "product_id", :integer
t.column "pages", :integer
t.column "author", :string
end
create_table "products", :force => true do |t|
t.column "name", :string
t.column "price", :integer
t.column "type", :string
end
create_table "videos", :force => true do |t|
t.column "product_id", :integer
t.column "minutes", :integer
t.column "starring", :string
end
class Product < ActiveRecord::Base
end
class Book < ActiveRecord::Base
inherits_from :product
end
class Video < ActiveRecord::Base
inherits_from :product
end
Book.create(:name => "Agile Development with Rails", :pages => 350)
Video.create(:name => "Twilight Zone Season 1", :minutes => 490)
Book.find(1).name => "Agile Development with Rails"
http://blog.raylucke.com/articles/2006/07/03/simple-class-table-inheritance-in-activerecord
http://guest@blog.raylucke.com/svn/inherits_from
Model
