Based on the code snippets you provided, it looks like you want two different things.
- An authenticated user to have a different root path than someone who isnât logged in.
- A new user to be directed to a wizard to help them get started.
The first step you seem to have under control. It looks like youâre using Devise, and you can pretty easily create a new root path for a user who isnât logged in.
The second part seems to be the place where you are running into the logic problem: âWhen is a good time to show a new user an onboarding wizard?â
It seems like youâre trying to use sign_in_count
as a measure for someone needing a wizard to get started, but there will likely be a couple UX problems with this user flow.
What happens when a user signs up, sees a multi-step wizard form, but is in a rush or too busy to be bothered about this form right now? They log out, quit the browser, and return to it later. When they return to your app the wizard is no longer there and they have an empty account and a new UI they havenât seen before? Most likely they will be lost, confused, and not properly be on-boarded into your app.
Unless they user has already paid for your app or absolutely need it, they likely wonât return.
I think you need a better way of deciding if a user needs a wizard or not.
Wizard logic on macOS
One of my favorite examples of this logic is with Appleâs macOS. When you log into a new Mac for the first time, the user is greeted with a friendly wizard to walk them through setting up their computer. Once they have finished setting up, their Mac will create a tiny file. /var/db/.AppleSetupDone
Every time the mac is started, it checks to see if that file is present. If the .AppleSetupDone
file exists, it brings the user right to the login screen. If it doesnât, the user will be brought to a wizard to set up their first Admin account.
If you want to rerun this wizard, you can simply delete the file and Apple will bring you back to the setup wizard.
I like this way more. This way, I can log in and out as many times as I want but I wonât be brought any further into the app than I am ready for.
Replicating this behavior.
I would direct the user to the wizard every time unless they have already finished the wizard.
In your situation, I would add a boolean column to my userâs table in the database called wizard_completed
with a default value of false
.
On the last step of my wizard, I would use the hidden_field
form helper to change wizard_completed
to true
.
In the dashboard#show
(or wherever your default âsign inâ button leads), I would use the controllerâs logic to redirect to the wizard if current_user.wizard_completed
is false
. This way the new user, logging in through the new siteâs (at least itâs new to them) sign in path, should be greeted with the wizard until they have completed it.
Again, let me know if this helps.
Cheers,
Pete