0

I'm trying to implement a multi-step registration process. This particular implementation involves OmniAuth, but for the purposes of this discussion it could well be any OAuth provider.

Here are the registration steps we might implement:

Step 1. User clicks Connect with _________.

Step 2. Authorize via _________ and redirect to callback. Pull relevant data from provider and save to your User model.

Step 3. Pick a username, fill out email address, and any other required data for registering for your app. Also save this to your User model.

The problem for me lies in the transition from Step 2 to Step 3. I could set validations on the data based on state, using something like state_machine, for example.

However, I would have to remove not-null constraints at the column level for certain essential pieces of data, like username in my case (which is used for user routes), or email. I'm not super comfortable removing another layer of data integrity.

I'm sure this problem has been solved a thousand times before. How have you handled it and how would you recommend I handle it?

Josh Smith
  • 14,674
  • 18
  • 72
  • 118
  • Check out http://stackoverflow.com/questions/2917604/rails-multi-step-new-user-signup-form-fsm – Thilo Oct 28 '12 at 23:18
  • @Thilo I've seen that screencast and it doesn't resolve my problem with the not-null constraints, same as with state_machine, unless I'm missing something. – Josh Smith Oct 29 '12 at 01:17

1 Answers1

0

Could you add the data from the provider as hidden fields in your form for step 3 to pick username, email address etc? This way you wouldn't be creating a User instance until you had all of the data available.

Jason Noble
  • 3,756
  • 19
  • 21
  • To clarify, Step 2 isn't really a form, it's just code executed within a controller. I *could* just render the data in a form with a GET request rather than save it, but I'm not sure how great an idea that is. – Josh Smith Oct 29 '12 at 01:48