, ,

Hi Folks/Fellow Developers,

As I’ve seen lot many examples, articles over Single Table Inheritance, I decided to write my own. Thanks to the open source contributors. Their Articles/Examples helped me a lot writing this post.

As you might know about single table inheritance, let me quickly set the definition for it. Single-Table-Inheritance (STI) allows you to write/create sub-classes of a specific model. You can use a single table, add specific objects and extend the functionality/behavior of base model.

Current example explained:

My Current example is based on Mobile system. We have a single model called ‘Mobile’ and other models such as ‘Samsung’, ‘Apple’, ‘Nokia’ etc., that inherits the property of Mobile model. (Refer to the image for more help)

Single Table Inheritance

Single Table Inheritance

Development Platform used:

Ruby - 1.9.3
Rails - 3.2.13
Bundler- 1.3.5
IDE - Netbeans 6.9.1

The application is currently hosted on GitHub and can be cloned using the below command:
git clone git@github.com:puneetpandey/rails3_singleTableInheritance.git

Let me know your feedback about this application.

Happy Coding!