ruby-on-rails – ActionMailer错误的参数个数错误

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – ActionMailer错误的参数个数错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个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

解决方法

我认为请求是一个保留字.尝试更改为request_mail,看看它是否有效.

猜你在找的Ruby相关文章