gpt4 book ai didi

ruby-on-rails - ActionMailer 错误的参数数量错误

转载 作者:数据小太阳 更新时间:2023-10-29 07:21:24 25 4
gpt4 key购买 nike

我有一个 Rails 应用程序,可以让您请求注册邀请。根据要求,我会保存您的电子邮件并向您发送一封电子邮件,表示感谢“您已请求加入”。出于某种原因,行 UserMailer.request(@request).deliver 给我这个错误 ArgumentError in RequestsController#create -- wrong number of arguments (0 for 1)

有什么想法吗?

请求 Controller

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

ma​​ilers/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

最佳答案

我认为request是一个保留字。尝试更改为 request_mail 并查看它是否有效。

关于ruby-on-rails - ActionMailer 错误的参数数量错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17331619/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com