views:

158

answers:

1

Hi all:

I am just starting to write ruby rails. I wrote a controller but is getting wrong number of "arguments (1 for 0)" error, I can't understand why. It has no information on where the error occurred? It has a full list of stack traces but my controller file is not in there!

In my controller I have just two methods, that I was going to test out activemq. But after I put the controller out, I got the above error, so I commented out all the code, but I still get the same error. I can't figure out why.

I searched google for ruby debug, I have not found anything helpful.

Here is my controller source:

class ActivemqTestController < ApplicationController
  def send
    #client = Stomp::Client.open("stomp://localhost:61613")
    #station_id=101
    #data = {'station_id' => station_id, 'username' => 'yangyanzhe'}
    #client.publish('/listener/add', data)
  end

  def receive
    #client = Stomp::Client.open("stomp://localhost:61613")
    # Processing loop
    #client.subscribe('/listener/add', headers) do |msg|
      # Process your message here
      # Your submitted data is in msg.body
      #puts msg['username'] + " joined " + msg['station_id'] + "\n"
      #client.acknowledge(msg)
    #end
    #client.join # Wait until listening thread dies
  end
end

This is the error:

ArgumentError in Activemq testController#index

wrong number of arguments (1 for 0)
RAILS_ROOT: D:/rubyapps/radio

Application Trace | Framework Trace | Full Trace
f:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:532:in `send'
f:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:532:in `process_without_filters'
f:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:606:in `process'
f:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:391:in `process'
f:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:386:in `call'
f:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:437:in `call'

Thank you for any help in advance.

+4  A: 

According to your log and Ruby's kind of special .send method (defined for all Objects), I recommend not to call your action send. Should fix the issue.

If you want your URL to look like .../send you can still fix that in the Router.

Marcel J.
O, thats why. Thank you. Still I think ruby could showed me a meaningful message
Darkerstar
I wonder why rails uses `.send` rather than `__send__`.
Andrew Grimm