2017-02-15 17 views
0

我想通過以下this post渲染我的rails應用程序中的錯誤頁面,但將其更改爲與Heroku一起使用。Rails + Heroku中的自定義錯誤頁面

帖子棧:Rails + Nginx + Capistrano。
我的堆棧:Rails + Heroku。

my-app.herokuapp.com/assets/XXX.html網址是工作,但我需要呈現my-app.herokuapp.com/XXX.html

我想我需要更改下面的代碼,從後拍攝,Heroku的工作!

root /myapp/current/public; 
error_page 404 /404.html; 
location /404.html { 
    internal; 
    root /myapp/current/public/assets; 
} 

回答

0

的Heroku是原來的職位您遵循完全不同:

每隔錯誤您的應用程序將會提供404,從HTML文件422和500在公共/目錄在你的應用程序默認。

對於503錯誤,你需要設置環境變量指向你想要的服務器發生錯誤時的靜態頁面:

heroku config:set ERROR_PAGE_URL=//s3.amazonaws.com/<your_bucket>/your_error_page.html 

爲其他自定義見https://devcenter.heroku.com/articles/error-pages#configure-your-application

+0

感謝但不是當rails應用程序發生異常時,不顯示heroku的自定義錯誤頁面。 當heroku發生錯誤時會出現錯誤頁面。我想處理我的rails應用程序的錯誤。 – edudepetris

+0

你是對的,我已經更新了我的答案,包括如何自定義404,422和500錯誤的錯誤消息。 – Leito

0

我沒有這個功能,前幾天,我發現物品,其最明顯的和有用的https://thepugautomatic.com/2014/08/404-with-rails-4/

但是如果你想處理500錯誤或其他你應該在路線和「CustomPublicExceptions」添加一個字符串將狀態添加到狀態

+0

謝謝,如果我找不到解決方案,我會給這個機會。 但我的想法是不使用Rails的東西(控制器)呈現錯誤,如果應用程序崩潰 – edudepetris