Ruby on Rails项目,我正在运行Resque来处理电子邮件(尤其是Devise和Devise Invitable)。 Devise电子邮件发送正常(通过API通过邮戳gem发出),但是devise_invitable电子邮件在Resque中失败,显示为undefined method invitation_instructions for #User:0x0xxxxxx Did you mean? invitations_count
。
通过默认的devmail发送时,一切正常,但是使用我的自定义邮件失败。我想添加一个内联附件,因此需要自定义邮件。
自定义设计邮件程序:
class DeviseMailer < Devise::Mailer helper :application include Devise::Controllers::UrlHelpers include Devise::Mailers::Helpers include DeviseInvitable::Mailer default template_path: 'devise/mailer' default from: [email protected] layout 'mailer_devise' before_action :add_inline_attachment! def reset_password_instructions(record, token, opts={}) super end def invitation_instructions(record, token, opts={}) @token = token devise_mail(record)#, record.invitation_instructions || :invitation_instructions, opts) end private def add_inline_attachment! attachments.inline['logo.png'] = File.read(Rails.root.join('app/assets/images/logo.png')) end end
摘要:
[def reset_password_instructions
-正常工作
def invitation_instructions
-失败,出现未定义的方法错误
Ruby on Rails项目,我正在运行Resque来处理电子邮件(尤其是Devise和Devise Invitable)。 Devise电子邮件发送正常(通过API通过邮戳gem发送出去),但是devise_invitable电子邮件...
由于其他原因,我最终迁移到Sidekiq。下面是我更新的Devise Mailer类,它运行良好。无需定义invitation_instructions
方法,因为before_action
回调附加了内嵌图像,这是我一开始所追求的。