views:

265

answers:

2

I have a model with many fields (nearly 40). The client wants the fields divided among multiple screens. The model also has a few has_manys that should look like they are part of the same model.

How can one divide the model, and what are the tradeoffs among the ways to do it?

I see a couple of possibilities:

1) Use JavaScript to show and hide parts of the form. I think I can make that one work.

2) Use forms that submit to different actions. Can form_for be used with appropriate options?

I'm looking for other ideas too.

+1  A: 

Check out acts as state machine. You can use this to create wizards and whatnot.

Having reread your question, I think Javascript is really what you're looking for. Check out jQuery UI, they've got a tab component that will probably help.

Tim Sullivan
Thanks for the link, Tim.I understand state machines well, but don't see how this will help, since I don't need to have a state, or proceed in a certain order. Or, if I do have a state, how do I get certain parts of the form on the page and get those to update properly?
Chris
Perhaps I misunderstood the question. If you're simply looking to show and hide items, Javascript is the way to go. If you're looking to split the contents of a single form across several pages, an SSM will let you track the page you're on as well as provide a mechanism for moving among them. Having reread your question, I think Javascript is really what you're looking for. Check out jQuery UI, they've got a tab component that will probably help.
Tim Sullivan
I started writing to use jQuery UI and tabs ... the only issue with this could be with usability - it may not be clear to the user where validation errors are occurring.
Toby Hede
Accepted as Tim's comment was just the thing.
Chris
A: 

I would check out the ActsAsWizard plugin. Makes doing a wizard like this extremely simple.

Check out the readme it is excellent.

XGamerX
Be aware that ActsAsWizard requires that the 40 fields in the one model be broken down into models though. It is really more for building data entry for an object and its relations via wizard rather than building one large model.
srboisvert