0
votes

I have a model and I want to allow users to edit different subsets of the model's attributes at different points. Consider a model with attributes A, B, C, D, E, and F.

I would like to have the model initially created with a form that has fields for A and B. Then at another step in the process I would like to show the user a form to edit the model and have that form have fields for C and D and E. At another point I would like to show them a form to edit the model and have that form have fields for A, E, and F. My actual situation is more complicated than this but for the sake of this question I believe this is adequate. What are different good ways to serve up those different forms? The only way I can think of right now is:

  • Have a different action and respective form for each case and create the requisite routes in the routes.rb file.
2

2 Answers

2
votes

Have you seen the Railscasts video that deals with multi-step forms?

I'm using a very similar implementation in my current project where a user can fill out their profile in parts...

0
votes

John, There are no restrictions on creating multiple views. You can create different partials or even full files and render them based on your own logic. The only practical issue you will run into is that of active record validations. You need a way to localize certain validations to certain forms. You can accomplish this using session, cookies et al. Another thing to look at it is whether you are collecting certain items only on :create, :update or some specific action method. If that is the case then you can use the ":on" qualifier to prevent the validations from firing at wrong time. The tutorial mentioned by Rob above is pretty good and I upvoted his answer. But it is one approach and you may find it easier to implement it in your own way using any of the other techniques I referred to.