Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionMailer wrong number of arguments error

I have a rails app that allows you to request an invite to sign up. Upon request I save your email and send you an email saying thanks 'you have requested to join in'. For some reason the line UserMailer.request(@request).deliver gives me this error ArgumentError in RequestsController#create -- wrong number of arguments (0 for 1)

Any ideas?

requests 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

mailers/user_mailer.rb

class UserMailer < ActionMailer::Base
  def request(request)
    @request = request
    mail(:to => request.email, :subject => "Requested an invite", :from => '[email protected]')
  end
end
like image 671
Alain Goldman Avatar asked Dec 06 '22 07:12

Alain Goldman


1 Answers

I think request is a reserved word. Try change to request_mail and see whether it works.

like image 67
shinnc Avatar answered Dec 20 '22 09:12

shinnc