0

The confirmation mail is sent automatically when a user is created. But I need to send the mail through code manually after completing a few more steps.

I can't able to prevent the confirmation mail from sending.

User model

class User < ActiveRecord::Base

   include DeviseTokenAuth::Concerns::User

   devise :database_authenticatable, :registerable,
     :recoverable, :rememberable, :trackable, :validatable,
     :confirmable

   before_create :skip_confirmation_notification!

I am using devise_token_auth with Grape API for rails.

Note: If I try to use skip_confirmation! it works perfectly without any flaw. But I don't need that functionality because I want to confirm the users only through the confirmation link sent to their mail.

1 Answers1

0

First you have to skip to send confirmation mail by doing this in your controller. put this code before the user save

resource.skip_confirmation_notification!
resource.save

so now confirmation mail will not sent than you can put conditions which you wants than when your condition is true. you can again send confirmation mail in by below code..

resource.send_confirmation_instructions

i personally tested it.. and it works great.. hope it will help you

Vishal
  • 7,113
  • 6
  • 31
  • 61
  • skip_confirmation! automatically confirms the user. But I want to confirm the user only through the mail link. – arparthasarathi Jul 16 '16 at 12:52
  • Thanks a lot for your valuable time buddy and sorry that I missed some important points in the question. Am using devise_token_auth with grape. So it would be better if I could handle it in model side as there are not controllers in my app. I am stuck with that. As I said, if I use skip_confirmation!, it works perfectly man – arparthasarathi Jul 16 '16 at 15:45