Rails Single Table Inheritance Helper Module

Posted on March 12, 2012

Single table inheritance is a somewhat controversial topic in Rails land. For me, I like the Rails magic that it brings and, you know, the inheritance. However, it can clearly be abused. Here is my one rule for using Single table inheritance:

The models share the same data, but have differenct behavior.

I’ve created a helper module for use with Single Table Inheritance. The main advantage of this module is the factory method, with takes a type param and creates the correct object type.


1 Reply to "Rails Single Table Inheritance Helper Module"

  • David
    March 27, 2012 (2:45 pm)
    Reply

    Hi Rebecca.. thanks for sharing your mind.. Can I ask you for a tiny example or tutorial of how to use your STI Helper Module in a Rails application?

    Cheers,
    David


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.