在测试环境下难以调试

时间:2014-12-17 07:39:49

标签: ruby-on-rails

难以在测试环境下调试

这是我第一次在测试环境

中运行

获取错误

undefined method `[]' for nil:NilClass

这个bug有点麻烦,

因为它不会给我任何其他信息

控制器

  def index
    binding.pry
    @tool_cvt_firmware_ui_tests = Tool::Cvt::FirmwareUiTest.all
  end

  def create
    @tool_cvt_firmware_ui_test = Tool::Cvt::FirmwareUiTest.new(tool_cvt_firmware_ui_test_params)
    binding.pry    

    respond_to do |format|
      if @tool_cvt_firmware_ui_test.save
        binding.pry
    end
 end   

路由

  localized do
    namespace :tool do
      namespace :cvt do
        resources :firmware_ui_tests
      end
    end    
  end

错误

[2014-12-17 15:27:13] ERROR NoMethodError: undefined method `[]' for nil:NilClass
  ruby/gems/2.1.0/gems/route_translator-3.2.4/lib/route_translator/extensions/action_controller.rb:8:in `block in set_locale_from_url'
  ruby/gems/2.1.0/gems/route_translator-3.2.4/lib/route_translator/extensions/action_controller.rb:24:in `with_host_locale'
  ruby/gems/2.1.0/gems/route_translator-3.2.4/lib/route_translator/extensions/action_controller.rb:8:in `set_locale_from_url'
  ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/callbacks.rb:424:in `block in make_lambda'
  ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/callbacks.rb:298:in `call'
  ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/callbacks.rb:298:in `block in halting'
  ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/callbacks.rb:166:in `call'
  ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/callbacks.rb:166:in `block in halting'
  ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/callbacks.rb:86:in `call'
  ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/callbacks.rb:86:in `run_callbacks'
  ruby/gems/2.1.0/gems/actionpack-4.1.6/lib/abstract_controller/callbacks.rb:19:in `process_action'
  ruby/gems/2.1.0/gems/actionpack-4.1.6/lib/action_controller/metal/rescue.rb:29:in `process_action'
  ruby/gems/2.1.0/gems/actionpack-4.1.6/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
  ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/notifications.rb:159:in `block in instrument'
  ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/notifications.rb:159:in `instrument'
  ruby/gems/2.1.0/gems/actionpack-4.1.6/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  ruby/gems/2.1.0/gems/actionpack-4.1.6/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
  ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  ruby/gems/2.1.0/gems/actionpack-4.1.6/lib/abstract_controller/base.rb:136:in `process'
  ruby/gems/2.1.0/gems/actionview-4.1.6/lib/action_view/rendering.rb:30:in `process'

关注档案

require 'active_support/concern'
module RemoteFwUiServer
  include ActiveSupport::Concern
  attr_accessor :params   

1 个答案:

答案 0 :(得分:0)

错误就是这一行attr_accessor :params

我删除后就可以了。

但是错误日志是如此模糊