Reputation: 714
I want to render the error pages on my rails app by following this post but change it to work with Heroku.
Post stack: Rails + Nginx + Capistrano.
My stack: Rails + Heroku.
my-app.herokuapp.com/assets/XXX.html
URL is working but I need to render my-app.herokuapp.com/XXX.html
I think I need to change the following code, taken from the post, to work with Heroku!
root /myapp/current/public;
error_page 404 /404.html;
location /404.html {
internal;
root /myapp/current/public/assets;
}
Upvotes: 1
Views: 1175
Reputation: 7167
Heroku is completely different to the original post you are following:
Every other error your app is going to serve 404, 422 and 500 from the html files in the public/ directory in your app by default.
For 503 errors you need to set the ERROR_PAGE_URL
environment variable that points to the static page you want to server when an error occurs:
heroku config:set ERROR_PAGE_URL=//s3.amazonaws.com/<your_bucket>/your_error_page.html
See https://devcenter.heroku.com/articles/error-pages#configure-your-application for other customizations.
Upvotes: 1
Reputation: 151
I did that feature few days ago, and I found that article which the most clear and useful https://thepugautomatic.com/2014/08/404-with-rails-4/
But if you want handle 500 error or another you should add one more string in routes and in 'CustomPublicExceptions' add condition to status
Upvotes: 0