我有一个rails应用程序,允许您请求邀请注册。根据要求,我保存您的电子邮件并向您发送一封电子邮件,表示感谢“您已请求加入”。由于某种原因,行UserMailer.request(@request).deliver
在RequestsController中创建了此错误ArgumentError #create - 错误的参数数量(0表示1)
有什么想法吗?
请求控制器
class RequestsController < ApplicationController
def new
@request = Request.new
end
def create
@request = Request.new(params[:request])
if @request.valid?
if User.find_by_email(@request.email) || Invitation.find_by_email(@request.email)
redirect_to log_in_path, notice: "Email already in use"
elsif @request.save
@request.save
redirect_to root_url, :notice => "Request sent."
UserMailer.request(@request).deliver
end
else
render "new"
end
end
end
request.html.haml
You have requested to join in
寄件人/ user_mailer.rb
class UserMailer < ActionMailer::Base
def request(request)
@request = request
mail(:to => request.email, :subject => "Requested an invite", :from => 'alain@lootfly.com')
end
end
答案 0 :(得分:12)
我认为request
是一个保留字。尝试更改为request_mail
并查看其是否有效。
答案 1 :(得分:3)
我还猜测你不能在模型Request中命名或者在你的控制器中有一个名为@request的实例变量