代码之家  ›  专栏  ›  技术社区  ›  Darkerstar

Ruby Rail调试输出

  •  0
  • Darkerstar  · 技术社区  · 15 年前

    我刚开始写ruby-rails。我写了一个控制器,但得到的“参数(0为1)”错误的数目,我不明白为什么。它没有错误发生在哪里的信息?它有一个完整的堆栈跟踪列表,但我的控制器文件不在那里!

    在我的控制器中,我只有两个方法,我要测试activemq。但是在我把控制器放出来之后,我得到了上面的错误,所以我注释掉了所有的代码,但是我仍然得到了同样的错误。我不明白为什么。

    我在google上搜索ruby debug,没有发现任何有用的东西。

    这是我的控制器源:

    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
    

    这是错误:

    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'
    

    提前谢谢你的帮助。

    1 回复  |  直到 15 年前
        1
  •  4
  •   Marcel Jackwerth    15 年前

    根据你的日志和鲁比的 special .send 方法(为所有对象定义),我建议不要调用您的操作 send . 应该能解决这个问题。

    如果你想让你的网址看起来像 .../send 你仍然可以在路由器中修复它。