Plugins - Inherits From

StarAdd to favorites

Implements 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"

Tags

Comments

Add a comment

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?