Homeland undefined method `unscoped' for nil:NilClass 求前辈知道,docker 安装之后宝了这个错误

wuyahui · 2020年03月01日 · 最后由 wuyahui 回复于 2020年03月02日 · 2888 次阅读

求前辈知道,docker 安装之后宝了这个错误

这个应该是你自己的代码写的有点问题吧,你的stats_controller的第 11 行是什么?把你访问的这个 controller 的代码贴上来看一下

qq792326645 回复

您好,我是直接安装的 docker 发行版本,没有下载和修改过代码

以下是全部日志

undefined method `unscoped' for nil:NilClass
Method:      GET
URL:         /admin/stats?model=note&by=month
Controller:  admin/stats#index
RequestId:   1f44af16-2e77-47fe-a113-f16e2df36fe5
User-Agent:  Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36
Remote IP:   172.18.0.8
Language:    zh-CN,zh;q=0.9,en;q=0.8
Server:      07e9bbdf06e7
Process:     30

--------------------------------------------------

#<NoMethodError: undefined method `unscoped' for nil:NilClass>


/home/app/homeland/app/controllers/admin/stats_controller.rb:11:in `index'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/abstract_controller/base.rb:196:in `process_action'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_controller/metal/rendering.rb:30:in `process_action'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.2.1/lib/active_support/callbacks.rb:135:in `run_callbacks'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/abstract_controller/callbacks.rb:41:in `process_action'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_controller/metal/rescue.rb:22:in `process_action'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.2.1/lib/active_support/notifications.rb:180:in `block in instrument'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.2.1/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.2.1/lib/active_support/notifications.rb:180:in `instrument'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_controller/metal/instrumentation.rb:32:in `process_action'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.2.1/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/abstract_controller/base.rb:136:in `process'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.2.1/lib/action_view/rendering.rb:39:in `process'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_controller/metal.rb:191:in `dispatch'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_controller/metal.rb:252:in `dispatch'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_dispatch/routing/route_set.rb:51:in `dispatch'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_dispatch/routing/route_set.rb:33:in `serve'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_dispatch/journey/router.rb:49:in `block in serve'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_dispatch/journey/router.rb:32:in `each'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_dispatch/journey/router.rb:32:in `serve'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_dispatch/routing/route_set.rb:837:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:192:in `call!'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:169:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/http_accept_language-2.1.1/lib/http_accept_language/middleware.rb:14:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/rack-attack-6.2.2/lib/rack/attack.rb:156:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/rack-attack-6.2.2/lib/rack/attack.rb:170:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/exception_notification-4.4.0/lib/exception_notification/rack.rb:36:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/warden-1.2.8/lib/warden/manager.rb:36:in `block in call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/warden-1.2.8/lib/warden/manager.rb:34:in `catch'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/warden-1.2.8/lib/warden/manager.rb:34:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/rack-2.2.2/lib/rack/tempfile_reaper.rb:15:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/rack-2.2.2/lib/rack/etag.rb:27:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/rack-2.2.2/lib/rack/conditional_get.rb:27:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/rack-2.2.2/lib/rack/head.rb:12:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_dispatch/http/content_security_policy.rb:18:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/rack-2.2.2/lib/rack/session/abstract/id.rb:266:in `context'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/rack-2.2.2/lib/rack/session/abstract/id.rb:260:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/cookies.rb:648:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.2.1/lib/active_support/callbacks.rb:101:in `run_callbacks'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/railties-6.0.2.1/lib/rails/rack/logger.rb:38:in `call_app'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/railties-6.0.2.1/lib/rails/rack/logger.rb:26:in `block in call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.2.1/lib/active_support/tagged_logging.rb:80:in `block in tagged'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.2.1/lib/active_support/tagged_logging.rb:28:in `tagged'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.2.1/lib/active_support/tagged_logging.rb:80:in `tagged'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/railties-6.0.2.1/lib/rails/rack/logger.rb:26:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/request_store-1.5.0/lib/request_store/middleware.rb:19:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/request_id.rb:27:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/rack-2.2.2/lib/rack/method_override.rb:24:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/rack-2.2.2/lib/rack/runtime.rb:22:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.2.1/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/executor.rb:14:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/rack-2.2.2/lib/rack/sendfile.rb:110:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/host_authorization.rb:77:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/rack-cors-1.1.1/lib/rack/cors.rb:100:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/railties-6.0.2.1/lib/rails/engine.rb:526:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/puma-4.3.1/lib/puma/configuration.rb:228:in `call'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/puma-4.3.1/lib/puma/server.rb:681:in `handle_request'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/puma-4.3.1/lib/puma/server.rb:472:in `process_client'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/puma-4.3.1/lib/puma/server.rb:328:in `block in run'
/home/app/homeland/vendor/bundle/ruby/2.6.0/gems/puma-4.3.1/lib/puma/thread_pool.rb:134:in `block in spawn_thread'

报错的是 https://github.com/ruby-china/homeland/blob/master/app/controllers/admin/stats_controller.rb#L11

result[:count] = klass.unscoped.count # Line 11
...
def klass                                                                      # Line 17
  params[:model].camelize.safe_constantize
end

你的 url 里是model=note,似乎代码里并没有这个 model。换一个别的试试看。

piecehealth 回复

那有可能是我 docker 部署的配置文件没对吗,没有加载到 node 纪事本模块,请问要怎么配置呀,配置了也重启了,就是没效果

wuyahui 关闭了讨论 03月03日 16:56
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册