我有一个大多数空白的Rails应用程序,我添加了设计,rolify和专家以及我的视图/控制器中的一些非常基本的用法。它在我的开发环境(Cloud 9)上运行良好。
然而,当我部署到Heroku时,构建说一切都很顺利,但我得到了一个通用的“我们很抱歉,但出了点问题。如果你是应用程序所有者,请查看日志以获取更多信息。”
所以我去检查了日志,我愿意打赌这是重要的一句话:
2016-04-05T22:58:08.451507+00:00 app[web.1]: ActionView::Template::Error (undefined method `has_role?' for nil:NilClass):
这对我来说表明新宝石没有正确安装。我尝试过明显的Heroku命令:
heroku run bundle update
heroku run bundle install
heroku run rake db:migrate
heroku run rails generate devise:install
heroku run rails generate pundit:install
以下是有帮助的完整日志。
2016-04-05T22:57:57.008177+00:00 heroku[router]: at=info method=GET path="/" host=agile-atoll-64419.herokuapp.com request_id=90f5e664-ebb5-4335-a99c-607497aaa5ad fwd="71.212.102.26" dyno=web.1 connect=7ms service=17ms status=500 bytes=1754
2016-04-05T22:57:56.999357+00:00 app[web.1]: Completed 500 Internal Server Error in 2ms (ActiveRecord: 0.0ms)
2016-04-05T22:57:56.999267+00:00 app[web.1]: Rendered static_pages/home.html.haml within layouts/application (1.2ms)
2016-04-05T22:57:57.000866+00:00 app[web.1]:
2016-04-05T22:57:57.000874+00:00 app[web.1]: ActionView::Template::Error (undefined method `has_role?' for nil:NilClass):
2016-04-05T22:57:57.000876+00:00 app[web.1]: 6: bolding
2016-04-05T22:57:57.000876+00:00 app[web.1]: 7: a word sucks.
2016-04-05T22:57:57.000877+00:00 app[web.1]: 8:
2016-04-05T22:57:57.000878+00:00 app[web.1]: 9: - if current_user.has_role? :admin
2016-04-05T22:57:57.000878+00:00 app[web.1]: 10: %h1
2016-04-05T22:57:57.000879+00:00 app[web.1]: 11: You very special
2016-04-05T22:57:57.000880+00:00 app[web.1]: app/views/static_pages/home.html.haml:9:in `_app_views_static_pages_home_html_haml___4111531422675686977_69828977231500'
2016-04-05T22:57:57.000881+00:00 app[web.1]:
2016-04-05T22:57:57.000882+00:00 app[web.1]:
2016-04-05T22:57:57.258300+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=agile-atoll-64419.herokuapp.com request_id=8781f959-5f3c-4472-ae63-90b77f28d206 fwd="71.212.102.26" dyno=web.1 connect=1ms service=4ms status=200 bytes=228
2016-04-05T22:57:57.619035+00:00 heroku[router]: at=info method=GET path="/" host=agile-atoll-64419.herokuapp.com request_id=226bef16-befe-49c9-ae1e-5e6d1bbf54ec fwd="71.212.102.26" dyno=web.1 connect=1ms service=10ms status=500 bytes=1754
2016-04-05T22:57:57.609261+00:00 app[web.1]: Started GET "/" for 71.212.102.26 at 2016-04-05 22:57:57 +0000
2016-04-05T22:57:57.611709+00:00 app[web.1]: Processing by StaticPagesController#home as HTML
2016-04-05T22:57:57.613456+00:00 app[web.1]: Rendered static_pages/home.html.haml within layouts/application (0.8ms)
2016-04-05T22:57:57.613571+00:00 app[web.1]: Completed 500 Internal Server Error in 2ms (ActiveRecord: 0.0ms)
2016-04-05T22:57:57.615218+00:00 app[web.1]:
2016-04-05T22:57:57.615226+00:00 app[web.1]: ActionView::Template::Error (undefined method `has_role?' for nil:NilClass):
2016-04-05T22:57:57.615226+00:00 app[web.1]: 6: bolding
2016-04-05T22:57:57.615227+00:00 app[web.1]: 7: a word sucks.
2016-04-05T22:57:57.615227+00:00 app[web.1]: 8:
2016-04-05T22:57:57.615228+00:00 app[web.1]: 9: - if current_user.has_role? :admin
2016-04-05T22:57:57.615228+00:00 app[web.1]: 10: %h1
2016-04-05T22:57:57.615229+00:00 app[web.1]: 11: You very special
2016-04-05T22:57:57.615230+00:00 app[web.1]: app/views/static_pages/home.html.haml:9:in `_app_views_static_pages_home_html_haml___4111531422675686977_69828977231500'
2016-04-05T22:57:57.615230+00:00 app[web.1]:
2016-04-05T22:57:57.615231+00:00 app[web.1]:
2016-04-05T22:57:57.841322+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=agile-atoll-64419.herokuapp.com request_id=6940dd49-5725-4db1-9f6c-f7806052ccb7 fwd="71.212.102.26" dyno=web.1 connect=1ms service=4ms status=200 bytes=228
2016-04-05T22:57:58.221603+00:00 heroku[router]: at=info method=GET path="/" host=agile-atoll-64419.herokuapp.com request_id=aaefa56e-cd4a-4c4e-bad6-e84106d3b674 fwd="71.212.102.26" dyno=web.1 connect=1ms service=10ms status=500 bytes=1754
2016-04-05T22:57:58.212005+00:00 app[web.1]: Started GET "/" for 71.212.102.26 at 2016-04-05 22:57:58 +0000
2016-04-05T22:57:58.214960+00:00 app[web.1]: Processing by StaticPagesController#home as HTML
2016-04-05T22:57:58.216890+00:00 app[web.1]: Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.0ms)
2016-04-05T22:57:58.216349+00:00 app[web.1]: Rendered static_pages/home.html.haml within layouts/application (0.8ms)
2016-04-05T22:57:58.218209+00:00 app[web.1]:
2016-04-05T22:57:58.218215+00:00 app[web.1]: ActionView::Template::Error (undefined method `has_role?' for nil:NilClass):
2016-04-05T22:57:58.218222+00:00 app[web.1]: 6: bolding
2016-04-05T22:58:01.835241+00:00 heroku[api]: Release v21 created by captainstack@outlook.com
2016-04-05T22:58:02.032509+00:00 heroku[slug-compiler]: Slug compilation started
2016-04-05T22:58:02.032517+00:00 heroku[slug-compiler]: Slug compilation finished
2016-04-05T22:58:01.997950+00:00 heroku[web.1]: Restarting
2016-04-05T22:58:01.999267+00:00 heroku[web.1]: State changed from up to starting
2016-04-05T22:58:03.798297+00:00 heroku[web.1]: Stopping all processes with SIGTERM2016-04-05T22:58:04.139416+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 46840 -e production`
2016-04-05T22:58:04.284082+00:00 app[web.1]: [2016-04-05 22:58:04] FATAL SignalException: SIGTERM
2016-04-05T22:58:04.284096+00:00 app[web.1]: /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/webrick/server.rb:174:in `select'
2016-04-05T22:58:04.284097+00:00 app[web.1]: /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/webrick/server.rb:174:in `block in start'
2016-04-05T22:58:04.284098+00:00 app[web.1]: /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/webrick/server.rb:32:in `start'
2016-04-05T22:58:04.284099+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:34:in `run'
2016-04-05T22:58:04.284099+00:00 app[web.1]: /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/webrick/server.rb:162:in `start'
2016-04-05T22:58:04.284100+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:286:in `start'
2016-04-05T22:58:04.284101+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/server.rb:80:in `start'
2016-04-05T22:58:04.284101+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/commands_tasks.rb:80:in `block in server'
2016-04-05T22:58:04.284102+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/commands_tasks.rb:75:in `tap'
2016-04-05T22:58:04.284103+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/commands_tasks.rb:75:in `server'
2016-04-05T22:58:04.284104+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
2016-04-05T22:58:04.284104+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands.rb:17:in `<top (required)>'
2016-04-05T22:58:04.284106+00:00 app[web.1]: bin/rails:9:in `require'
2016-04-05T22:58:04.284106+00:00 app[web.1]: bin/rails:9:in `<main>'
2016-04-05T22:58:04.284168+00:00 app[web.1]: [2016-04-05 22:58:04] INFO going to shutdown ...
2016-04-05T22:58:04.284741+00:00 app[web.1]: [2016-04-05 22:58:04] INFO WEBrick::HTTPServer#start done.
2016-04-05T22:58:04.284751+00:00 app[web.1]: Exiting
2016-04-05T22:58:04.969907+00:00 heroku[web.1]: Process exited with status 143
2016-04-05T22:58:07.503949+00:00 app[web.1]: [2016-04-05 22:58:07] INFO WEBrick 1.3.1
2016-04-05T22:58:07.503975+00:00 app[web.1]: [2016-04-05 22:58:07] INFO ruby 2.2.4 (2015-12-16) [x86_64-linux]
2016-04-05T22:58:07.504217+00:00 app[web.1]: [2016-04-05 22:58:07] INFO WEBrick::HTTPServer#start: pid=3 port=46840
2016-04-05T22:58:08.030328+00:00 heroku[web.1]: State changed from starting to up
2016-04-05T22:58:08.378582+00:00 app[web.1]: => Run `rails server -h` for more startup options
2016-04-05T22:58:08.378581+00:00 app[web.1]: => Rails 4.2.5.2 application starting in production on http://0.0.0.0:46840
2016-04-05T22:58:08.378566+00:00 app[web.1]: => Booting WEBrick
2016-04-05T22:58:08.378583+00:00 app[web.1]: => Ctrl-C to shutdown server
2016-04-05T22:58:08.378584+00:00 app[web.1]: Started GET "/" for 71.212.102.26 at 2016-04-05 22:58:08 +0000
2016-04-05T22:58:08.422572+00:00 app[web.1]: Processing by StaticPagesController#home as HTML
2016-04-05T22:58:08.449667+00:00 app[web.1]: Rendered static_pages/home.html.haml within layouts/application (9.4ms)
2016-04-05T22:58:08.449867+00:00 app[web.1]: Completed 500 Internal Server Error in 27ms (ActiveRecord: 0.0ms)
2016-04-05T22:58:08.451507+00:00 app[web.1]: ActionView::Template::Error (undefined method `has_role?' for nil:NilClass):
2016-04-05T22:58:08.451498+00:00 app[web.1]:
2016-04-05T22:58:08.451508+00:00 app[web.1]: 6: bolding
2016-04-05T22:58:08.451508+00:00 app[web.1]: 7: a word sucks.
2016-04-05T22:58:08.451509+00:00 app[web.1]: 8:
2016-04-05T22:58:08.451509+00:00 app[web.1]: 9: - if current_user.has_role? :admin
2016-04-05T22:58:08.451510+00:00 app[web.1]: 10: %h1
2016-04-05T22:58:08.451510+00:00 app[web.1]: 11: You very special
2016-04-05T22:58:08.451511+00:00 app[web.1]: app/views/static_pages/home.html.haml:9:in `_app_views_static_pages_home_html_haml__1971063212221799350_69837704252740'
2016-04-05T22:58:08.451511+00:00 app[web.1]:
2016-04-05T22:58:08.451512+00:00 app[web.1]:
2016-04-05T22:58:08.453473+00:00 heroku[router]: at=info method=GET path="/" host=agile-atoll-64419.herokuapp.com request_id=61a0e4c4-c417-4e33-926e-3ea845bf7b1e fwd="71.212.102.26" dyno=web.1 connect=0ms service=79ms status=500 bytes=1754
2016-04-05T22:58:08.686821+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=agile-atoll-64419.herokuapp.com request_id=ad9a4986-b761-4054-9165-5033270bdf8f fwd="71.212.102.26" dyno=web.1 connect=0ms service=5ms status=200 bytes=228
任何想法是什么?
答案 0 :(得分:1)
current_user
是零。确保您已经登录并在拨打电话之前检查是否存在current_user。