I'm trying to render a custom error page for all 404 and 500 errors. So I have defined two methods not_found and internal_server_error in ErrorController class.
class ErrorController < ApplicationController
def not_found
#method which renders custom error page
render_error()
end
def internal_error
#method which renders custom error page
render_error()
end
end
and in my config/routes.rb I've included
get '/404', to: 'error#not_found'
get '/500', to: 'error#internal_error'
and in config/application.rb I've initialized config.exceptions_app as
config.exceptions_app = self.routes
But when I enter URL as http://localhost:3000/404 , I'm still getting the default page provided by rails and not my custom error page.
Any clue about what I'm doing wrong would be helpful.
Update:
I'm using ruby 2.3.4 and rails 5.0.5
Well it turns out that the variable config.consider_all_requests_local
was set to true and hence my requests weren't being routed to custom error pages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With