Ruby on rails 在自定义设计邮件程序中生成确认url
出于各种原因,我使用mandrillapi来处理我的事务性电子邮件。我遇到的一个问题是在新邮件程序中生成确认url、编辑密码url和解锁url。我在新邮件中包含Desive的URL帮助程序。电子邮件中的所有其他内容都已正确生成 我得到以下错误:Ruby on rails 在自定义设计邮件程序中生成确认url,ruby-on-rails,ruby-on-rails-4,devise,mandrill,Ruby On Rails,Ruby On Rails 4,Devise,Mandrill,出于各种原因,我使用mandrillapi来处理我的事务性电子邮件。我遇到的一个问题是在新邮件程序中生成确认url、编辑密码url和解锁url。我在新邮件中包含Desive的URL帮助程序。电子邮件中的所有其他内容都已正确生成 我得到以下错误: NoMethodError (undefined method `main_app' for #<DeviseMailer:0x007f812b6abe78>): app/mailers/devise_mailer.rb:15:in `c
NoMethodError (undefined method `main_app' for #<DeviseMailer:0x007f812b6abe78>):
app/mailers/devise_mailer.rb:15:in `confirmation_instructions'
app/controllers/lenders/registrations_controller.rb:9:in `create'
NoMethodError(未定义的#的方法'main_app'):
app/mailers/designe_-mailer.rb:15:in“确认说明”
app/controllers/leaders/registrations\u controller.rb:9:in'create'
designe\u mailer.rb
class DeviseMailer < MandrillMailer::TemplateMailer
helper :application
include Devise::Controllers::UrlHelpers
default from: 'no-reply@test.com'
def confirmation_instructions(record, token)
mandrill_mail template: 'Confirmation Instructions',
subject: 'Confirm Email',
from_name: 'Test',
to: { email: record.email },
vars: {
'FNAME' => record.first_name,
'LIST_COMPANY' => "Apples",
'HTML_LIST_ADDRESS_HTML' => "1 Infinite Loop",
'CONFIRMATION_LINK' => confirmation_url(record, :confirmation_token => token)
}
end
end
class designemailerrecord.first\u name,
“列出公司”=>“苹果”,
'HTML\u LIST\u ADDRESS\u HTML'=>“1无限循环”,
“确认链接”=>确认url(记录:确认令牌=>令牌)
}
结束
结束
感谢您对任何遇到此问题的人的帮助——我在使用相同的方法替换Desive的客户邮件时遇到了遗漏问题 使用上面的例子,我像这样修复了它
class DeviseMailer < MandrillMailer::TemplateMaile
# ..... mailer code in here here .....
private
def main_app
Rails.application.routes.default_url_options[:host] = Rails.application.routes.default_url_options[:host]
Rails.application.routes.url_helpers
end
end
class designemailer