Topic: Polymorphic Forms...
In my application I have two types of user accounts -- "Personal" and "Shared". Shared accounts are used by group entities such that all the officers in the organization share a username/password. (I'm tired of them just creating "people" with the firstname='teamname' and lastname='officers".)
I'm using STI, so I have a "User" Model with the email, password, and username fields. PersonalAccount adds a foreign key to a Person (which gets to firstname, lastname, etc), while SharedAccount just adds a "Display Name".
So far almost all of the code can deal with User interface exclusively. However the new account creation process is causing me a few conceptual issues. I'm using a wizard like process -- step one establishes all the common fields and uses radio buttons to select between the two account types. Step two then shows either the firstname,lastname combination or the displayname field. (Of course onces its all working, this is a prime place for an AJAX enchancement to just change what fields are on the form.)
How would you end up structuring the code in the view for the step two? I've been thinking about using two partials with an if (changing to a case if I ever add a third account type) in the view code. However that screams non-OOP to me. A slightly more OOPy approach would be to have the User subclasses respond_to a "partial_for" or similar message, but that seems to add a view dependency to the model which is normally a no-no. Can anyone help straighten me out here?
(I haven't started tackling the controller yet, but I assume I'll bump into the same types of issues there...)