Sha256: 902bb6e4ed4f1c0a55c0e1f171c80430a50ce9713b15ce7f99a7ee687ce4b50b

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

ClassTableInheritance
=====================

 This is an ActiveRecord plugin designed to allow 
 simple multiple table (class) inheritance.
 
 This plugin was inspired by:
 inherits_from plugin => http://github.com/rwl4/inherits_from and
 Multiple Table Inheritance with ActiveRecord => http://mediumexposure.com/multiple-table-inheritance-active-record/

Example
=======

  # Migrations 

  create_table :product do |t|
    t.string :description, :null => false
    t.decimal :price
    t.timestamps
  end
  
  create_table :book, :inherits => :product do |t|
    t.string :author, :null => false
  end
  
  create_table :videos, :inherits => :product do |t|
    t.string :year, :null => false
    t.string :genre, :null => false
  end

  # Models

  class Product < ActiveRecord::Base
  end

  class Book < ActiveRecord::Base
    inherits_from :product
  end

  class Video < ActiveRecord::Base
    inherits_from :product
  end

  book = Book.find(1)
  book.name => "Agile Development with Rails"
  book.author => "Dave Thomas"
  book.price => 19.00
  
  video = Video.find(2)
  video.name => "Inseption"
  video.year => "2010"
  video.genre => "SCI-FI" 
  video.price => 22.00
  
  book = Book.new
  book.name = "Hamlet"
  book.author = "Shakespeare, William"
  book.price => 14.00
  book.save
  
  if you need help contanct me: bfscordeiro (at) gmail.com .


Copyright (c) 2010 Bruno Cordeiro, released under the MIT license

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
class-table-inheritance-1.0.0 README