【发布时间】:2015-01-05 11:07:06
【问题描述】:
出于各种原因,我使用 Mandrill API 来处理我的交易电子邮件。我遇到的一个问题是在新邮件中生成confirmation_url、edit_password_url 和unlock_url。我在新邮件程序中包含了 Devise 的 URL 助手。电子邮件中的所有其他内容均已正确生成。
我收到以下错误:
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'
devise_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
感谢您的帮助
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 devise mandrill