How to stop Devise from delivering emails when creating a user?

I have a user controller that creates users, for example:

User.create! :blah => "whatever"

My problem is that it generates an email, for example when someone signs up, and I need to create my own email with much more information. Is there a way to get Devise not to generate this email?

+3
source share
3 answers

I still needed to create a token, so my code turned out to be the same. This is a quick and dirty solution, and it can be improved, but at least it shows how to do it:

user.confirmed_at = Time.now
user.save!
user.confirmed_at = nil
user.send(:generate_confirmation_token)
user.save!
+2
source

You can also use newinstead createand call skip_confirmationup to save:

user = User.new :blah => "whatever"
user.skip_confirmation!
user.save

skip_confirmation confirmed_at, .

+6

, devise , , , .

, . , , views/devise/mailer/confirmation_instructions.html.erb, .

Another approach would be to overwrite the default mailbox , which designs and configures your own custom file in initializers / devise.rb by setting config. mailer to your personalized mailer. Then in your custom mailer, you can overwrite the method confirmation_instructions(record)so that it sends your new email.

0
source

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


All Articles