未定义的方法`deliver_sent”的MailerFormError:类(undefined m

2019-10-30 04:47发布

我升级赖斯2.3.2项目轨道3

错误:


undefined method `deliver_sent' for MailerFormError:Class
Application Trace | Framework Trace | Full Trace
app/controllers/leads_controller.rb:72:in `block in create'
app/controllers/leads_controller.rb:56:in `create'

MailerFormError是我的模型: class MailerFormError < ActionMailer::Base

这是在型号和的ActionMailer :: Base的都没法“deliver_sent”太多:(

与它的代码的控制器:



    @msg = {}
    @msg["errors"] = @lead.errors
    @msg["params"] = params
    MailerFormError.deliver_sent(@msg)

的ActionMailer版:的ActionMailer(3.2.11)

我怎么解决这个问题?

Answer 1:

发送电子邮件改变2.3和3.2之间的很多。 这是一个基本的HOWTO: http://xyzpub.com/en/ruby-on-rails/3.2/action_mailer.html



Answer 2:

1)为Rails 3,发送您的通知,您的控制器,我写这篇文章:


    MailerFormError.sent(@msg).deliver

2)我重写你的“发送”方法在Rails 3的方式:


    def sent(msg, sent_at = Time.now)
      ...
      mail(:to => '...', :from => '...', :subject => '...') do |format|
        format.html
        format.text
      end
      ...
    end

最后,我在创建视图目录应用程序/视图/ mail_form_error文本版本和HTML:sent.text.erb和sent.html.erb



文章来源: undefined method `deliver_sent' for MailerFormError:Class