1
我有範圍的意見reset_password_instructions.html設計不會覆蓋電子郵件意見
,並在我的devise.rb
config.scoped_views = true
它工作正常發展,併發送定製的電子郵件。但是,在製作中,當用戶收到電子郵件時,設備會發送一個默認模板。
如何解決此問題?
我有範圍的意見reset_password_instructions.html設計不會覆蓋電子郵件意見
,並在我的devise.rb
config.scoped_views = true
它工作正常發展,併發送定製的電子郵件。但是,在製作中,當用戶收到電子郵件時,設備會發送一個默認模板。
如何解決此問題?
當我使用色器件我這就是我做派我自己的電子郵件
class MyMailer < Devise::Mailer
helper :application # gives access to all helpers defined within `application_helper`.
include Devise::Controllers::UrlHelpers # Optional. eg. `confirmation_url`
default template_path: 'devise/mailer' # to make sure that your mailer uses the devise views
end
現在,在你config/initializers/devise.rb
,您可以設置config.mailer
到"MyMailer"
。
您現在可以像使用其他郵件程序一樣使用MyMailer。如果你想覆蓋特定的郵件來添加額外的頭文件,你可以通過簡單地覆蓋方法並在自定義方法結束時調用super來觸發Devise的默認行爲。
您還可以通過手動設置選項哈希覆蓋任何基本報頭(來自REPLY_TO等):
def confirmation_instructions(record, token, opts={})
headers["Custom-header"] = "Bar"
opts[:from] = '[email protected]'
opts[:reply_to] = '[email protected]'
super
end
爲了得到預覽(如果用戶是你的色器件型號名稱):
# test/mailers/previews/my_mailer_preview.rb
# Preview all emails at http://localhost:3000/rails/mailers/my_mailer
class MyMailerPreview < ActionMailer::Preview
def confirmation_instructions
MyMailer.confirmation_instructions(User.first, "faketoken", {})
end
def reset_password_instructions
MyMailer.reset_password_instructions(User.first, "faketoken", {})
end
def unlock_instructions
MyMailer.unlock_instructions(User.first, "faketoken", {})
end
end
我希望這是有益的:)
好,我在app /郵寄/ my_mailer.rb – pedroooo
創建和設置config.mailer = 「MyMailer」 和工作? – pedroooo
是的,這是計劃 –