जब आप डेविस सेट करते हैं, तो आप इसे बताते हैं कि यह किस मॉडल पर काम कर रहा है (उदा। उपयोगकर्ता); इसके कई तरीके/उसके बाद अधिकांश वर्ग उस वर्ग पर लागू होते हैं। तो वह जगह है जहां आप सामान को ओवरराइड करना चाहते हैं।
यहां lib/devise/models/authenticatable.rb
पर डेविस कोड से एक टिप्पणी है जो ठीक से पढ़ रहा है, तो लगभग वही वर्णन करता है जो आप करना चाहते हैं।
# 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
स्रोत
2012-10-11 02:59:21
धन्यवाद तो आप कह रहे हैं कि मेरे user.rb फ़ाइल में "send_devise_notification" जोड़ें? मैंने कोशिश की और इसे नहीं बुलाया गया ... – AnApprentice
हां, अपने उपयोगकर्ता मॉडल में 'send_devise_notification' ओवरराइड करें। मैं डेविस के वर्तमान संस्करण के साथ अधिसूचना को अवरुद्ध करने में सक्षम था (मैंने इसे साबित करने के लिए लॉग में कुछ भेजा है)। लेकिन सब कुछ काम करने के लिए, टिप्पणी पढ़ें - यह विधि को परिभाषित करने की बात नहीं है, आपको देरी वाली नौकरी (या जो कुछ भी) कतार बनाने के लिए 'after_commit' फ़िल्टर भी जोड़ना होगा। –
धन्यवाद लेकिन यह वह जगह नहीं है जहां "send_confirmation_instructions" रहता है? और मुझे उस विधि को "send_confirmation_instructions" – AnApprentice