Today, I would like to show you an improved way to manage Single Table Inheritance with ActiveScaffold. It s a real time safer.
STI Models should hopefully have a big overlap of attributes, which is the base assumption for my implementation of STI in ActiveScaffold.

Basically, we will show an index view of parent sti controller, in which member actions such as edit, show,delete are linking to corresponding specific sti controller. Create link opens a popup menu showing the different sti models.

That s the concept let s try it out. I will use an example from the book: “Agile Web Development with Rails” written by Dave Thomas and David Heinemeier Hansson.
That example consist of the following models:

Person (sti_parent)

Customer

Employee (Parent of Manager)

Manager

It s quite tedious to set up an application with these models, therefore we will shorten that process.

Setup Example Application

Great, we ve prepared our example application, now we have to configure our controllers

Controller Inheritance

ActiveScaffold configuration can be inherited, which is quite useful for sti, because many columns are shared.

class CustomersController < PeopleController

class EmployeesController < PeopleController

class ManagersController < EmployeesController

Definition of column set for each Controller

We have to define for each controller, which columns we would like to use. Please note that we do not have to define anything specific for manager controller because it should use same settings as employee controller.

Yes, ActiveScaffold is a available as gem. I think it s a great step forward and it will be easier than ever to integrate activescaffold into your projects. Finally, we ve managed to get it up and running and I would like to thank Chris Shoemaker for his contribution to this project.

Let me introduce to you the different options you have to integrate activescaffold into your project: