0

I have added Devise with my Rails app and I am using the confirmable module. Then I integrated devise with Stripe.

I found out that when I try to register a user and the payment goes wrong, Devise still sends a confirmation email. When I check if a user was created in the rails console I found that no new user exists. I don't understand why this happens. I feel like it wasn't suppose to be acting like that.

I found out about the confirm! method of devise but I am not sure how can I override it so that the user must first be created before sending this email.

Then I thought, the user might be created and because the payment failed to be destroyed then?! Not sure, I surely didn't code something like that.

Any tip or suggestion on how to handle this?

1 Answers1

3

Use skip_confirmation! to send confirmation instructions later, just call it before saving the user record

@user.skip_confirmation!

You can send confirmation instructions later by using send_confirmation_instructions method

@user.send_confirmation_instructions

I don't know what exactly you are doing, but I can give you an example

@user.skip_confirmation!
if @user.save
  @user.send_confirmation_instructions
end
Rajdeep Singh
  • 17,621
  • 6
  • 53
  • 78