petehamilton / citier

CITIER (Class Inheritance & Table Inheritance Embeddings for Rails) is a solution for simple Multiple Class Inheritance in Rails.
88 stars 24 forks source link

Save on root class creates new child model based on :type #38

Open jonlhouse opened 12 years ago

jonlhouse commented 12 years ago

Hi, Here's a feature request:

Quick version... I'd like to be able to create a new child model with:

child = Parent.new( :type => 'Child', :child_specific_param => 'something', .... rest of params ...)

I could create multiple controllers or have one controller with a switch statement in the create action to instantiate different class objects based on the type parameter. However, I think it would be cleaners and DRYer to implement this functionality in the gem itself.

I have a forked version I'll play around with but I'm still new to the code so if someone else wants to have a go at it, kudos.

Thanks, John

jonlhouse commented 12 years ago

Forgot to add... here's a reference thread on STI doing something similar: http://stackoverflow.com/questions/435678/rails-single-table-inheritance-what-is-the-best-way-to-explicitly-set-type