我正在尝试部署使用Ruby on Rails创建的应用程序。部署成功,但是当我访问站点时,出现错误。我是Heroku的新手,我无法理解问题在部署日志中的位置。
2019-05-22T00:17:23.122780+00:00 heroku[router]: at=info method=GET path="/" host=blocipediaproject.herokuapp.com request_id=a9b00b68-9cfa-4c60-8c58-92fc961071e6 fwd="76.168.120.33" dyno=web.1 connect=1ms service=4ms status=500 bytes=1827 protocol=https
2019-05-22T00:17:23.120564+00:00 app[web.1]: [a9b00b68-9cfa-4c60-8c58-92fc961071e6] Started GET "/" for 76.168.120.33 at 2019-05-22 00:17:23 +0000
2019-05-22T00:17:23.121394+00:00 app[web.1]: [a9b00b68-9cfa-4c60-8c58-92fc961071e6] Processing by WikisController#index as HTML
2019-05-22T00:17:23.121647+00:00 app[web.1]: index action is running
2019-05-22T00:17:23.122793+00:00 app[web.1]: [a9b00b68-9cfa-4c60-8c58-92fc961071e6] Completed 500 Internal Server Error in 1ms
2019-05-22T00:17:23.123145+00:00 app[web.1]: [a9b00b68-9cfa-4c60-8c58-92fc961071e6]
2019-05-22T00:17:23.123182+00:00 app[web.1]: [a9b00b68-9cfa-4c60-8c58-92fc961071e6] NoMethodError (undefined method `role' for nil:NilClass):
2019-05-22T00:17:23.123207+00:00 app[web.1]: [a9b00b68-9cfa-4c60-8c58-92fc961071e6]
2019-05-22T00:17:23.123233+00:00 app[web.1]: [a9b00b68-9cfa-4c60-8c58-92fc961071e6] app/policies/wiki_policy.rb:39:in `resolve'
2019-05-22T00:17:23.123234+00:00 app[web.1]: [a9b00b68-9cfa-4c60-8c58-92fc961071e6] app/controllers/wikis_controller.rb:8:in `index'
2019-05-22T00:22:22.275221+00:00 heroku[router]: at=info method=GET path="/" host=blocipediaproject.herokuapp.com request_id=793d8d10-47f9-40f9-b982-be8de6cf9eab fwd="76.168.120.33" dyno=web.1 connect=0ms service=4ms status=500 bytes=1827 protocol=https
2019-05-22T00:22:22.274745+00:00 app[web.1]: [793d8d10-47f9-40f9-b982-be8de6cf9eab] Started GET "/" for 76.168.120.33 at 2019-05-22 00:22:22 +0000
2019-05-22T00:22:22.275375+00:00 app[web.1]: [793d8d10-47f9-40f9-b982-be8de6cf9eab] Processing by WikisController#index as HTML
2019-05-22T00:22:22.275650+00:00 app[web.1]: index action is running
2019-05-22T00:22:22.276891+00:00 app[web.1]: [793d8d10-47f9-40f9-b982-be8de6cf9eab] Completed 500 Internal Server Error in 1ms
2019-05-22T00:22:22.277273+00:00 app[web.1]: [793d8d10-47f9-40f9-b982-be8de6cf9eab]
2019-05-22T00:22:22.277326+00:00 app[web.1]: [793d8d10-47f9-40f9-b982-be8de6cf9eab] NoMethodError (undefined method `role' for nil:NilClass):
2019-05-22T00:22:22.277361+00:00 app[web.1]: [793d8d10-47f9-40f9-b982-be8de6cf9eab]
2019-05-22T00:22:22.277404+00:00 app[web.1]: [793d8d10-47f9-40f9-b982-be8de6cf9eab] app/policies/wiki_policy.rb:39:in `resolve'
2019-05-22T00:22:22.277407+00:00 app[web.1]: [793d8d10-47f9-40f9-b982-be8de6cf9eab] app/controllers/wikis_controller.rb:8:in `index'
这是我的wiki_policy中我的resolve方法的代码。
def resolve
wikis = []
if user.role == 'admin'
wikis = scope.all
elsif user.role == 'premium'
scope.where(private: [false, nil] || wiki.owner == user ||
wiki.collaborators.include ? (user))
elsif user.role == 'standard'
scope.where(private: [false, nil] || wiki.collaborators.include ?
(user))
else
scope.where(private: [false, nil])
end
end