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.