jbd-ARXITx83Qt49fbuuu1rVSg@public.gmane.org
2005-Jul-14 18:12 UTC
actionmailer bug in 0.13.1?
Hi all, I just upgraded my application to 0.13.1, and emails stopped being delivered from it. The symptom is that no matter how I call deliver_foo from my controller, rails throws an exception "wrong number of arguments (n+1 for 0), where n is the number of arguments I gave the deliver_foo method. the actionmailer method_missing method I''ve got has logging added. It looks like this: class << self def method_missing(method_symbol, *parameters)#:nodoc: case method_symbol.id2name when /^create_([_a-z]\w*)/ File.open(''/tmp/justin.log'',''a'') {|f| f << "calling new create with #{$1} and #{parameters.inspect}\n" } new($1, *parameters).mail when /^deliver_([_a-z]\w*)/ then File.open(''/tmp/justin.log'',''a'') {|f| f << "calling new delivery with #{$1} and #{parameters.inspect}\n" } new($1, *parameters).deliver! when "new" then nil else super end end The line number mentioned in the exception is the one with the new($1,*parameters). So it looks like AM is calling new() which expects 0 arguments, with at least $1 (1 argument). What''s going on here? An example exception: Mailer error: appmail UNverified delivery: wrong number of arguments (5 for 0) /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `initialize'' /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `new'' /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `new'' /usr/lib/ruby/gems/1.8/gems/actionmailer-1.0.1/lib/action_mailer/base.rb:343:in `method_missing'' /app/controllers/mail_controller.rb:399:in `send_appmail'' /app/controllers/mail_controller.rb:372:in `new'' /app/controllers/mail_controller.rb:372:in `each'' /app/controllers/mail_controller.rb:372:in `new'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:756:in `send'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:756:in `perform_action_without_filters'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/filters.rb:295:in `perform_action_without_benchmark'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in `perform_action_without_rescue'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in `measure'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in `perform_action_without_rescue'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/rescue.rb:80:in `perform_action'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:356:in `send'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:356:in `process'' /usr/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/dispatcher.rb:32:in `dispatch'' /home/jbd/cvs/code/om/myapp/public/dispatch.cgi:10 -- Justin
Fixed it! My ApplicationMailer class had an initialize method defined, and in order fo that to work, it had to take (*args) and pass *args to the super call as well. -- Justin On Thu, 14 Jul 2005 jbd-ARXITx83Qt49fbuuu1rVSg@public.gmane.org wrote:> Hi all, > > I just upgraded my application to 0.13.1, and emails stopped being > delivered from it. > > The symptom is that no matter how I call deliver_foo from my controller, > rails throws an exception "wrong number of arguments (n+1 for 0), > where n is the number of arguments I gave the deliver_foo method. > > the actionmailer method_missing method I''ve got has logging added. It > looks like this: > > class << self > def method_missing(method_symbol, *parameters)#:nodoc: > case method_symbol.id2name > when /^create_([_a-z]\w*)/ > File.open(''/tmp/justin.log'',''a'') {|f| f << "calling new > create with #{$1} and #{parameters.inspect}\n" } > new($1, *parameters).mail > when /^deliver_([_a-z]\w*)/ then > File.open(''/tmp/justin.log'',''a'') {|f| f << "calling new > delivery with #{$1} and #{parameters.inspect}\n" } > new($1, *parameters).deliver! > when "new" then nil > else super > end > end > > The line number mentioned in the exception is the one with the > new($1,*parameters). > > So it looks like AM is calling new() which expects 0 arguments, with > at least $1 (1 argument). What''s going on here? > > An example exception: > > Mailer error: appmail UNverified delivery: wrong number of arguments (5 for > 0) > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `initialize'' > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `new'' > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `new'' > /usr/lib/ruby/gems/1.8/gems/actionmailer-1.0.1/lib/action_mailer/base.rb:343:in > `method_missing'' > /app/controllers/mail_controller.rb:399:in `send_appmail'' > /app/controllers/mail_controller.rb:372:in `new'' > /app/controllers/mail_controller.rb:372:in `each'' > /app/controllers/mail_controller.rb:372:in `new'' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:756:in > `send'' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:756:in > `perform_action_without_filters'' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/filters.rb:295:in > `perform_action_without_benchmark'' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in > `perform_action_without_rescue'' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in > `measure'' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in > `perform_action_without_rescue'' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/rescue.rb:80:in > `perform_action'' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:356:in > `send'' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:356:in > `process'' > /usr/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/dispatcher.rb:32:in `dispatch'' > /home/jbd/cvs/code/om/myapp/public/dispatch.cgi:10 > >