Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

config.exceptions_app not working in rails

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

like image 660
Raghavendra Bableshwar Avatar asked Aug 21 '17 21:08

Raghavendra Bableshwar


1 Answers

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.

like image 125
Raghavendra Bableshwar Avatar answered Oct 22 '22 23:10

Raghavendra Bableshwar