Search code examples
ruby-on-railsdevisewizarduser-registration

User registration server-side wizard with Devise authentication


All the authentication plugins I've seen are implementing one-page user registration - user enters all his fields and then they are submitted at once. So the Devise authentication does.

Bun now we have requirements to do multi-page registration wizard.

Implementing it with JQuery with posting on last wizard's page would be easy if we haven't a requirement that user should be created on the very first page and then, on other pages should provide more and more information with saving after each page submit.

How would you suggest to implement this in a project which is using Devise authentication? How does this correspond to user's activation process (I mean sending account confirmation e-mails)?


Solution

  • Multistep forms have nothing to do with any authentication plugin you use. It depends on how you integrate it.

    The complexity becomes much harder since you have multiple requests from page to page.
    - How do I keep the data?
    - When do I create the database model?
    - Should I use hidden fields an pass the values from page to page or should I stick them in the session?

    Those are all questions that pop up at some point and you should try sorting them out beforehand.

    Creating the model on the initial request has the big disadvantage that you could end up with a bogus database entry, which obviously you don't want.

    You could create a temporary model for instance, that you use for collecting the userdata and at the end you create your real usermodel, going through devise, based on this tmp model and delete it when you're done...

    Ryan Bates talks in one of his screencasts about multistep forms. http://railscasts.com/episodes/217-multistep-forms

    might be interesting for you to watch.