我真的只是不确定这意味着什么或我应该做什么才能使网页在我的localhost上工作。现在它只是显示一个错误,上面写着“我们很抱歉,但出了点问题。”当我在Chrome中运行rails server
并打开localhost:3000
时。
这是控制台输出:
Started GET "/users/sign_in" for 127.0.0.1 at 2013-07-05 12:07:07 -0400
Processing by Devise::SessionsController#new as HTML
Completed 500 Internal Server Error in 55ms
NoMethodError (undefined method `empty?' for nil:NilClass):
actionpack (3.2.11) lib/action_view/lookup_context.rb:145:in `detail_args_for'
actionpack (3.2.11) lib/action_view/lookup_context.rb:139:in `args_for_lookup'
actionpack (3.2.11) lib/action_view/lookup_context.rb:109:in `find'
actionpack (3.2.11) lib/action_view/renderer/abstract_renderer.rb:3:in `find_template'
actionpack (3.2.11) lib/action_view/renderer/template_renderer.rb:34:in `determine_template'
newrelic_rpm (3.5.5.38) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:153:in `render_with_newrelic'
actionpack (3.2.11) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.2.11) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.2.11) lib/abstract_controller/rendering.rb:110:in `_render_template'
actionpack (3.2.11) lib/action_controller/metal/streaming.rb:225:in `_render_template'
actionpack (3.2.11) lib/abstract_controller/rendering.rb:103:in `render_to_body'
actionpack (3.2.11) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
actionpack (3.2.11) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
actionpack (3.2.11) lib/abstract_controller/rendering.rb:88:in `render'
actionpack (3.2.11) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.2.11) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.2.11) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/Users/Alex/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
activesupport (3.2.11) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.2.11) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.2.11) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
activerecord (3.2.11) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
actionpack (3.2.11) lib/action_controller/metal/instrumentation.rb:39:in `render'
remotipart (1.0.5) lib/remotipart/render_overrides.rb:14:in `render_with_remotipart'
actionpack (3.2.11) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (3.2.11) lib/action_controller/metal/responder.rb:232:in `default_render'
actionpack (3.2.11) lib/action_controller/metal/responder.rb:160:in `to_html'
actionpack (3.2.11) lib/action_controller/metal/responder.rb:153:in `respond'
actionpack (3.2.11) lib/action_controller/metal/responder.rb:146:in `call'
actionpack (3.2.11) lib/action_controller/metal/mime_responds.rb:239:in `respond_with'
devise (2.2.3) app/controllers/devise/sessions_controller.rb:10:in `new'
actionpack (3.2.11) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.11) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.11) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.11) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.11) lib/active_support/callbacks.rb:447:in `_run__4160102059982529417__process_action__1687296135628327387__callbacks'
activesupport (3.2.11) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.11) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.11) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.11) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.11) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.11) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.11) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.11) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.11) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.11) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.11) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.11) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
newrelic_rpm (3.5.5.38) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:34:in `block in process_action'
newrelic_rpm (3.5.5.38) lib/new_relic/agent/instrumentation/controller_instrumentation.rb:268:in `block in perform_action_with_newrelic_trace'
newrelic_rpm (3.5.5.38) lib/new_relic/agent/method_tracer.rb:240:in `trace_execution_scoped'
newrelic_rpm (3.5.5.38) lib/new_relic/agent/instrumentation/controller_instrumentation.rb:263:in `perform_action_with_newrelic_trace'
newrelic_rpm (3.5.5.38) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:33:in `process_action'
actionpack (3.2.11) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.11) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.11) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.11) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.11) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.11) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.11) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.11) lib/action_dispatch/routing/route_set.rb:36:in `call'
actionpack (3.2.11) lib/action_dispatch/routing/mapper.rb:42:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.11) lib/action_dispatch/routing/route_set.rb:601:in `call'
rack-pjax (0.7.0) lib/rack/pjax.rb:12:in `call'
newrelic_rpm (3.5.5.38) lib/new_relic/rack/error_collector.rb:8:in `call'
newrelic_rpm (3.5.5.38) lib/new_relic/rack/browser_monitoring.rb:12:in `call'
newrelic_rpm (3.5.5.38) lib/new_relic/rack/developer_mode.rb:24:in `call'
warden (1.2.1) lib/warden/manager.rb:35:in `block in call'
warden (1.2.1) lib/warden/manager.rb:34:in `catch'
warden (1.2.1) lib/warden/manager.rb:34:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.5) lib/rack/etag.rb:23:in `call'
rack (1.4.5) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/head.rb:14:in `call'
remotipart (1.0.5) lib/remotipart/middleware.rb:30:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.11) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.11) lib/active_support/callbacks.rb:405:in `_run__1343605869620971269__call__1397566206717956287__callbacks'
activesupport (3.2.11) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.11) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.11) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.11) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.11) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.11) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.11) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.11) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.11) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.5) lib/rack/lock.rb:15:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.11) lib/rails/engine.rb:479:in `call'
railties (3.2.11) lib/rails/application.rb:223:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.11) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
/Users/Alex/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
/Users/Alex/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
/Users/Alex/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
答案 0 :(得分:11)
其他答案一般都是正确的。特别是此异常是由旧版本的newrelic_rpm gem和Ruby 2.0之间的不兼容引起的。请参阅rails #8885。
更新newrelic_rpm gem,它应该消失。
答案 1 :(得分:0)
它是方法detail_args_for
中的空引用异常(技术上是Nil引用异常)。您试图在具有Nil值的变量上调用方法empty?
,这会导致问题,因为它没有在nil中定义
答案 2 :(得分:0)
您正在.empty?
方法中某个尚未初始化的变量上调用detail_args_for
。如果您想要允许Nil值,可能需要在.nil?
之前添加对.empty?
的额外调用:
if(!someVar.nil? && someVar.empty?)