我不明白为什么我的第二个simple_form用开信器..。
我的代码如下:
estimations_controller.rb
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
endestimation_mailer.rb
class EstimationMailer < ApplicationMailer
def request(estimation)
@estimation = estimation
mail(
to: "name@example.com",
)
end
endrequest.html.erb
<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,它运行得很好。对于第二个,我找不到我的错误..。
非常感谢你的帮助。
发布于 2016-05-24 16:31:55
永远不要使用请求作为模型..。像这样简单!
https://stackoverflow.com/questions/37259958
复制相似问题