自定义404和500页在Heroku上不起作用

时间:2019-02-15 02:28:57

标签: ruby-on-rails heroku

我正在尝试自定义404和500页。我遵循了这个instruction。他们在本地主机上工作,但不在我的heroku上工作。我阅读了日志并在Google上搜索,但这并没有帮助。

我还设置了“ heroku config:set \ ERROR_PAGE_URL = //”,但它仍然对我不起作用。

有人可以帮助我吗?谢谢!
这是我的代码:

路线:

match "/404", :to => "errors#not_found", :via => :all
match "/500", :to => "errors#internal_server_error", :via => :all


控制器:

class ErrorsController < ApplicationController
  def not_found
    render(status: 404)
  end

  def internal_server_error
    render(status: 500)
  end
end


这是heroku日志中的错误: (我删除了一些行,因为当我尝试放置所有日志时,stackoverflow认为它们是垃圾邮件。)

2019-02-15T01:48:52.648590+00:00 app[web.1]: [8fb89276-6417-4ce7-bdc0-983742f3deae]     16:     </div>
2019-02-15T01:48:52.648592+00:00 app[web.1]: [8fb89276-6417-4ce7-bdc0-983742f3deae]     17:   </div>
2019-02-15T01:48:52.648593+00:00 app[web.1]: [8fb89276-6417-4ce7-bdc0-983742f3deae]     18: </div>
2019-02-15T01:48:52.648622+00:00 app[web.1]: F, [2019-02-15T01:48:52.648565 #4] FATAL -- : [8fb89276-6417-4ce7-bdc0-983742f3deae]
2019-02-15T01:48:52.648694+00:00 app[web.1]: F, [2019-02-15T01:48:52.648629 #4] FATAL -- : [8fb89276-6417-4ce7-bdc0-983742f3deae] app/views/errors/not_found.html.erb:15:in `_app_views_errors_not_found_html_erb___827346864636336380_47121411394000'
2019-02-15T01:48:52.648696+00:00 app[web.1]: [8fb89276-6417-4ce7-bdc0-983742f3deae] app/controllers/errors_controller.rb:3:in `not_found'
2019-02-15T01:48:52.649344+00:00 app[web.1]: I, [2019-02-15T01:48:52.649275 #4]  INFO -- : [8fb89276-6417-4ce7-bdc0-983742f3deae] Processing by ErrorsController#internal_server_error as HTML
2019-02-15T01:48:52.650719+00:00 app[web.1]: I, [2019-02-15T01:48:52.650641 #4]  INFO -- : [8fb89276-6417-4ce7-bdc0-983742f3deae]   Rendering errors/internal_server_error.html.erb within layouts/application
2019-02-15T01:48:52.652729+00:00 app[web.1]: I, [2019-02-15T01:48:52.652657 #4]  INFO -- : [8fb89276-6417-4ce7-bdc0-983742f3deae]   Rendered errors/internal_server_error.html.erb within layouts/application (1.9ms)
2019-02-15T01:48:52.652912+00:00 app[web.1]: I, [2019-02-15T01:48:52.652849 #4]  INFO -- : [8fb89276-6417-4ce7-bdc0-983742f3deae] Completed 500 Internal Server Error in 3ms (ActiveRecord: 0.0ms)
2019-02-15T01:48:52.652990+00:00 app[web.1]: Error during failsafe response: The asset "cry.jpeg" is not present in the asset pipeline.
2019-02-15T01:48:52.652819+00:00 heroku[router]: at=info method=GET path="/404" host=task-training.herokuapp.com request_id=8fb89276-6417-4ce7-bdc0-983742f3deae fwd="114.136.2.88" dyno=web.1 connect=0ms service=17ms status=500 bytes=377 protocol=https
2019-02-15T01:48:53.336051+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=task-training.herokuapp.com request_id=01343100-f222-434d-b1fc-bfb4625be46a fwd="114.136.2.88" dyno=web.1 connect=0ms service=2ms status=200 bytes=143 protocol=https
2019-02-15T01:48:53.376982+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=task-training.herokuapp.com request_id=21fe0d2e-933b-4753-bcef-07ab92f0241f fwd="114.136.2.88" dyno=web.1 connect=0ms service=4ms status=200 bytes=143 protocol=http
2019-02-15T01:48:56.173943+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=task-training.herokuapp.com request_id=c483976b-e696-43fc-9289-436a149c7626 fwd="66.85.185.84" dyno=web.1 connect=0ms service=1ms status=200 bytes=143 protocol=http

0 个答案:

没有答案