I want to test the 500 error pages in my Rails app using the development environment.
I already tried this in config/environments/development.rb
:
Just do a http://localhost:3000/404 or /500 to access these pages and see how they look like.
You should add the below lines to the application_controller,
unless ActionController::Base.consider_all_requests_local
rescue_from Exception, :with => :render_500
if ActiveRecord::RecordNotFound
rescue_from Exception, :with => :render_404
end
rescue_from ActionController::RoutingError, :with => :render_404
rescue_from ActionController::UnknownController, :with => :render_404
rescue_from ActionController::UnknownAction, :with => :render_404
end
Then try running with the below settings.
config.action_controller.consider_all_requests_local = false
in config/environments/development.rb:
It will work. Please dont forget to write the function in application_controller.rb to render the layout for each of the error messages.
I think the proper setting to twiddle is this:
config.action_view.debug_rjs = false
Why it's still labelled rjs
isn't entirely clear.
In addition to setting:
config.consider_all_requests_local = false
I also needed to set:
config.action_dispatch.show_exceptions = true
None of the proposed solutions worked in my Rails 3 app. The quick and dirty solution for me was to simply hit the error pages directly to see the rendered HTML. For example,
http://0.0.0.0:3000/404.html
http://0.0.0.0:3000/500.html
The only way I've found to do this so far is to set in development.rb
config.consider_all_requests_local = false
Then access the URLs using my local IP address: http://192.168.1.135:3000/blah
The other settings mentioned don't seem to have any effect.