2

Can't seem to get it working...it's still showing the default error pages...

using RAILS 4

Here is my code..

ErrorsController

def not_found
  render :status => 404
end

def unacceptable
  render :status => 422
end

def internal_error
  render :status => 500
end

Application.rb

config.exceptions_app = self.routes

Routes.rb

match "/404", :to => "errors#not_found", via: 'get'
match "/422", :to => "errors#unacceptable", via: 'get'
match "/500", :to => "errors#internal_error", via: 'get'

And i have the appropriate view with all those files

Why does it still render the default rails error messages?

2 Answers 2

6

you can go to config/environments/development.rb and change the following line,

config.consider_all_requests_local = true

to

config.consider_all_requests_local = false

Although I haven't tried this out myself, it is supposed to enable error messages while in development. The default allows for you to see debug mode.

Sign up to request clarification or add additional context in comments.

Comments

2

Also be aware the the error pages are not displayed in a :development environment

3 Comments

But if you go to localhost:300/404 in the dev env it will render error pages...i understand you cant get to them by their intended purposes (going to a wrong url)
Why is this so? Make's it difficult to style it?? Guess i'll just make a random page and style it then transfer the code over to the error page lol LAME Thanks @dtt101
Or maybe because the Routing Error -page is far more useful while developing? :P

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.