Reputation: 3058
I am debugging a application and i see one setting as
config.consider_all_requests_local = false
in config/environments/staging.rb and a 500.html file in public directory.
So if the status in header is 500, does rails display 500.html automatically? or do i need to make additional settings so that if exception occurs display 500.html
i am using rails 3.1, any help on this will be appriciated
Upvotes: 1
Views: 2140
Reputation: 20033
Yes, it automatically loads the static html files public/500.html and public/404.html.
Being static files, these do not go through the usual Rails pipeline.
For other message codes, or if you want to customize your error messages with advanced stuff like Ruby code and/or database access, you need to do the following:
ErrorsController
with it's correspondent actions and views.# config/routes.rb
get "500", to "errors#error_500", code: "500"
# app/controllers/ErrorsController.rb
class ErrorsController < ApplicationController
def error_500
end
end
Upvotes: 1
Reputation: 6545
Yes.
14.1 The Default 500 and 404 Templates
By default a production application will render either a 404 or a 500 error message. These messages are contained in static HTML files in the public folder, in 404.html and 500.html respectively. You can customize these files to add some extra information and layout, but remember that they are static; i.e. you can't use RHTML or layouts in them, just plain HTML.
Upvotes: 2