Project

mti

0.0
No release in over 3 years
Low commit activity in last 3 years
Implemention Multiple Table Inheritance in Rails
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
 Project Readme

Mutiple Table Inheritance (MTI)¶ ↑

<img src=“https://badge.fury.io/rb/mti.svg” alt=“Gem Version” /> <img src=“https://travis-ci.org/VishalTaj/mti.svg?branch=master” alt=“Build Status” />

Description¶ ↑

MTI is a gem designed to allow Multiple Table Inheritance for Rails Application. This will give us the previlage to access or assign sub-model attributes from parent model .

Like has_one association has_subclass also follows one_to_one mapping. This method should only be used if the other class contains the foreign key.

Use joins to query through this association.

eg: ParenModel.joins(:child_model).where(child_model: {abc: 'xyz'})

Installation¶ ↑

Add this to line gem list and run bundle install

$ gem `mti`

Run this command in terminal

$ rails g mti:install

Setup¶ ↑

To create a SubClass run command

$ rails g mti:subclass ChildModel ParentModel

Add has_subclass association to ParentModel

$ has_subclass :child_model

Test¶ ↑

If you are using this gem for the first time please do a migration for our dummy app.

$ cd test/dummy/app/ && rake db:migrate

Once done with the migration go back to the gem root directory then:

$ rake test

That’s all! you are ready to go… :)