Al configurar Diseñar, te dice que cuál es el modelo que está trabajando en (usuario, por ejemplo); muchos/la mayoría de sus métodos se aplican a esa clase. Entonces ahí es donde querrás anular cosas.
Aquí hay un comentario del código Devise en lib/devise/models/authenticatable.rb
que describe casi exactamente lo que quiere hacer, si estoy leyendo correctamente.
# This is an internal method called every time Devise needs
# to send a notification/mail. This can be overriden if you
# need to customize the e-mail delivery logic. For instance,
# if you are using a queue to deliver e-mails (delayed job,
# sidekiq, resque, etc), you must add the delivery to the queue
# just after the transaction was committed. To achieve this,
# you can override send_devise_notification to store the
# deliveries until the after_commit callback is triggered:
#
# class User
# devise :database_authenticatable, :confirmable
#
# after_commit :send_pending_notifications
#
# protected
#
# def send_devise_notification(notification)
# pending_notifications << notification
# end
#
# def send_pending_notifications
# pending_notifications.each do |n|
# devise_mailer.send(n, self).deliver
# end
# end
#
# def pending_notifications
# @pending_notifications ||= []
# end
# end
#
def send_devise_notification(notification)
devise_mailer.send(notification, self).deliver
end
Gracias, ¿está diciendo agregar "send_devise_notification" a mi archivo user.rb? Intenté eso y no se llamó ... – AnApprentice
Sí, anule 'send_devise_notification' en su modelo de Usuario. Pude interceptar la notificación (acabo de enviar algo al registro para demostrar que funciona) con una versión actual de Devise. Pero para que todo funcione, lea el comentario: no solo se trata de definir el método, sino que también debe agregar el filtro 'after_commit' para crear la cola del trabajo retrasado (o lo que sea). –
Gracias, pero esto no es donde vive "send_confirmation_instructions"? y necesito modificar ese método "send_confirmation_instructions" – AnApprentice