I'm trying to use STI in my models, while writing a little cms.
A have a model called Page and some subclasses like ContentPage,
Sysfolder etc. Some classes share similar attributes, so I use STI and
one table for all types.
Now I'm writing a form for edititing a page and I want to have the
opportunity to change the type of it at runtime. But that seems to be
When I do:
page = Page.find(x) # page.type is Sysfolder
page.update_attributes(params[:record]) # with
params[:record][:type] = ContentPage
page.type = ContentPage # or page[:type] = ContentPage
everything is saved, but not the type. When I try to debug the class
of page I get Sysfolder (thanks to STI) and I think here lies the
problem, because I cannot change the class at runtime. I tried a lot
af things like creating a new page and try to copy it over, but none
Is there a workaround or option I do not see right now?