Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm using

      user.skip_confirmation!

To skip the devise email confirmation when a new user is added by an existing user. The problem with the skip_confirmation is that it does not generate a confirmation token.

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

How can I skip the devise confirmation email yet still generate a confirmaton_token to allow me to manually send a custom confirmation email to added users?

Thanks

like image 952
AnApprentice Avatar asked Jul 29 '12 02:07

AnApprentice


2 Answers

@user = User.new(:email => '[email protected]', :password => 'password') 
@user.skip_confirmation_notification!
@user.save 

Here skip_confirmation_notification! generate a confirmation token but does not send confirmation email.

like image 163
Shamsul Haque Avatar answered Oct 14 '22 10:10

Shamsul Haque


See confirmable.rb. In particular, around line 253 - 256. I think that should help you out.

In short:

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
like image 44
Benjamin Tan Wei Hao Avatar answered Oct 14 '22 08:10

Benjamin Tan Wei Hao