I'm using Devise to implement user signup/login. I want the user to be able to login automatically after a successful sign up. How can I do that. It might be the case that Devise this by default, but then maybe I disabled that setting somewhere. I can't remember...
You have to:
1) Register the user into the website for devise. 2) Login the user.
For option 1, you can do something like:
if @user.save
sign_in(@user)
end
redirect_to after_sign_in_path(@user)
The things to have in mind, the first line tries to find for the user, on the second line, if it cannot find the user, it creates the user right away, then it sign_in the user, and finally redirect the user to where he should go after the login.
I think you have enabled the Devise Confirmable module in your Devise setup.
If that is the case, you can either remove the confirmable module or you can allow users to have unconfirmed access for a specific period.
In your config/initializers/devise.rb:
config.allow_unconfirmed_access_for = 2.days
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With