Devise - create confirmed user account without sending out an email?

less than 1 minute read

So you integrated devise in your app and need your email signups to confirm. You setup devise and enabled confirmable module and things were going great.

One day your manager comes to you all excited about having social logins(Facebook, twitter, linkedin) and you no longer need them to confirm. Or it may be that your application now has email invitation feature and it would be stupid to ask the user you just invited via email to confirm their email.

It is now time to skip confirmation mail.

For this you will have to detect the mechanism by which user is being created and If it is among above two cases you can add one more line user.skip_confirmation! before saving the user.

user = User.new(user_attrs)
user.skip_confirmation!
user.save!

Did this work for you? Do you have some more edge case related to this? Feel free to share in the comments below.

Happy Coding!

Reference: https://stackoverflow.com/a/7465664/4096120

Tags:

Categories:

Updated:

Leave a comment