From: Robert Klemme Date: 2006-08-05T04:40:12+09:00 Subject: Re: Bizarre Argument Error Harris Reynolds wrote: > Hello. I am hitting a nasty error where the Ruby interpreter is only expecting one argument for a particular method call, but it is actually declared to have three arguments. The error is happening when trying to invoke this method... > > def dispatch(cgi = nil, session_options = ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, output = $stdout) > .... > end > > Below are the two error messages when using two different web servers to try to invoke the request: > > # > ["C:/sdks/ruby/1.8.4/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb:115:in `dispatch'", > > ..and... > > Error calling Dispatcher.dispatch # > C:/sdks/ruby/1.8.4/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel/rails.rb:73:in `dispatch' > > The real pain comes in when looking at the source for both cases, webrick_server.rb:115 and mongrel/rails.rb:73 and noticing that the calls *do* have three arguments, and the method definition is expecting three arguments. > > Any idea why the interpreter would only think one argument required for this method? I'd double check that the method that is invoked is actually the one you think. Maybe there is a dynamic method redefinition or some other method shadows the method you think is called. Did you try to check the method? You can do something like this: irb(main):001:0> s="s" => "s" irb(main):002:0> m = s.method :gsub => # irb(main):003:0> p m; p m.arity # -1 => nil With that you see where the method is defined and the # of args. HTH robert