Rails: Devise: sending email after registration by comfirms

My application uses Devise and correctly sends confirmation letters, as well as correctly confirming users after they click on the confirmation link. I would also like to send a second letter AFTER user confirmation.

There are many tips on how to defer confirmation or confirmation from two steps, but nothing was found that I can find (that I can find).

The documentation of Devise :: Module :: Confirmable tells me that the method to use is a confirmation !, but I'm not sure how to do this. Any ideas?

+4
source share
1 answer

Rails Devise: after_confirmation

Just define an after_save callback that checks if the user is verified, and if so, sends an email.

If you want to save several processor cycles, you can override the ConfirmationController element with something like this:

class ConfirmationsController < Devise::ConfirmationsController def show self.resource = resource_class.confirm_by_token(params[:confirmation_token]) if resource.errors.empty? set_flash_message(:notice, :confirmed) if is_navigational_format? sign_in(resource_name, resource) # Send the user a second email send_post_confirmation_email respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) } else respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render :new } end end end 
+3
source

Source: https://habr.com/ru/post/1415906/


All Articles