首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带有信函_opener/mailer的“错误的参数数”

带有信函_opener/mailer的“错误的参数数”
EN

Stack Overflow用户
提问于 2016-05-16 17:41:10
回答 1查看 165关注 0票数 1

我不明白为什么我的第二个simple_form用开信器..。

我的代码如下:

estimations_controller.rb

代码语言:javascript
复制
class EstimationsController < ApplicationController
  def create@estimation = Estimation.new(estimation_params)
    if @estimation.save
      EstimationMailer.request(@estimation).deliver_now
      redirect_to root_path
    else
      render 'estimations/new'
    end
  end
end

estimation_mailer.rb

代码语言:javascript
复制
class EstimationMailer < ApplicationMailer
  def request(estimation)
    @estimation = estimation
   mail(
      to:      "name@example.com",
    )
  end
end

request.html.erb

代码语言:javascript
复制
<div class="container">
  <div class="row">
    <div class="col-xs-6 col-xs-offset-3">
      Hello,
      Yo got new message from <%= "#{@estimation.first_name}" %>
    </div>
  </div>
</div>

我最终得到了错误消息,如:

ArgumentError at /estimations错误的参数数(给定0,预期1)

在文件上:app/mailers/estimation_mailer.rb

然而,当我在本页中使用“引发”时,“估计”是存在的。

这是非常奇怪的:我在网站上为另一个表单设置了mailer/mailer_opener,它运行得很好。对于第二个,我找不到我的错误..。

非常感谢你的帮助。

EN

回答 1

Stack Overflow用户

发布于 2016-05-24 16:31:55

永远不要使用请求作为模型..。像这样简单!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37259958

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档