2
votes

I have a pretty standard mailer class with the following method:

def request(contact_us)
  @contact = contact_us
  mail(:to => "customercare@our_co.com", :subject => @contact.subject, :from => @contact.email)
end

The error I'm getting is:

wrong number of arguments (0 for 1)

My first thought that is was the argument being passed in but some debugging/specs confirm the error occurs on the line with mail(:to. The whole trace is below, line 9 is where the method is defined and line 11 is the mail method. I looked through the rails code and this is the method that's actually bailing in ActionView::Base

assign_controller(controller)

Any thoughts or suggestions? I have also tried RC5 with the same result.

Thanks!

ArgumentError: wrong number of arguments (0 for 1) from /Users/user/Git/projects/app/mailers/notifier.rb:9:in request' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/action_view/helpers/controller_helper.rb:15:inassign_controller' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/action_view/base.rb:212:in initialize' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/abstract_controller/rendering.rb:87:innew' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/abstract_controller/rendering.rb:87:in view_context' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/abstract_controller/rendering.rb:120:in_render_template' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/abstract_controller/rendering.rb:114:in render_to_body' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/abstract_controller/rendering.rb:99:inrender' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/base.rb:717:in block in collect_responses_and_parts_order' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/base.rb:728:ineach' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/base.rb:728:in each_template' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/base.rb:713:incollect_responses_and_parts_order' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/base.rb:652:in mail' from /Users/user/Git/projects/app/mailers/notifier.rb:11:inrequest' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/abstract_controller/base.rb:167:in process_action' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/abstract_controller/base.rb:121:inprocess' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionpack-3.1.0.rc4/lib/abstract_controller/rendering.rb:45:in process' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/old_api.rb:65:inprocess' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/base.rb:473:in process' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/base.rb:468:ininitialize' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/base.rb:455:in new' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/actionmailer-3.1.0.rc4/lib/action_mailer/base.rb:455:inmethod_missing' from (irb):13 from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/railties-3.1.0.rc4/lib/rails/commands/console.rb:45:in start' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/railties-3.1.0.rc4/lib/rails/commands/console.rb:8:instart' from /Users/user/.rvm/gems/ruby-1.9.2-p290@projects/gems/railties-3.1.0.rc4/lib/rails/commands.rb:40:in <top (required)>' from script/rails:6:inrequire'

1
Please provide some more code around using your request method.Maxim Filatov
I ended up regenerating the mailer with different class and method names and that solved the problem. I'm not sure but on second though having a method called 'request' seamed a bit dangerous.hkelsey
I've found both request and notify seem to cause problemsTheozaurus

1 Answers

3
votes

I had the same issue. It seems ActionMailer::Base doesn't like you use a request method for sending email. Change the method's name and it will work.