Creating a multi-stage Rails model

What is a good way to implement multi-stage model creation in rails? By this I mean that instead of one long form, the user fills one part, and then fills the next part on another page. In essence, this is a multi-part form with each part on a different page.

How to save user input for each part of the form? I also do field checks; How to handle validation in Rails so that each part of the form is validated separately? (If I put all the checks in the model, the form will never be successfully validated, because the fields that the user cannot see are never filled. Yes, javascript is an option, I want to process the validation in Rails so that it works even with javascript disabled).

+4
source share
2 answers

Ryan Bates did a screencast directly related to this, I highly recommend that you check:

http://railscasts.com/episodes/217-multistep-forms

+4
source

The magic stone is designed for this. It is very comfortable. My fork: https://github.com/paulschreiber/wizardly

Note that this does not work with Rails 3.x; It requires Rails 2.3.x or later.

+2
source

Source: https://habr.com/ru/post/1333370/


All Articles