Posted about 5 years ago. Visible to the public.

Inherit without Single-Table-Inheritance (STI) in ActiveRecord

You have multiple options:

  1. Just don't have a type column. All STI magic will be disabled automatically.
  2. If you have a type column but want to use it for something else (WAT?), you can set self.inheritance_column = :_non_existing_column in the class definition
  3. (Untested) In the parent class, set self.abstract_class = true

This technique is useful to implement form models / presenters, where you want all the goodness of ActiveRecord but want to add additional logic for a particular screen (e.g. class SignUp < User).

Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Author of this card:

Henning Koch
Last edit:
about 5 years ago
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Henning Koch to makandra dev