Rails Devise, how to skip a confirmation email, but still create a confirmation token?

I use

      user.skip_confirmation!

To skip developer email confirmation when a new user adds an existing user. The problem with skip_confirmation is that it does not generate a confirmation token.

I want to send a confirmation email manually, which means I need a confirmation token.

How can I skip the development confirmation email, but still create a confirmaton_token file so that I can manually send a confirmation email to add users?

thank

+5
source share
2 answers

. confirmable.rb. , 253-256. , .

:

module Devise
  module Models
    module Confirmable
      module ClassMethods
        # Generate a token checking if one does not already exist in the database.
        def confirmation_token
          generate_token(:confirmation_token)
        end
      end
    end
  end
end
+2
@user = User.new(:email => 'email@example.com', :password => 'password') 
@user.skip_confirmation_notification!
@user.save 

skip_confirmation_notification! , .

+18

All Articles