Skip to content

Instantly share code, notes, and snippets.

@smockle
Last active December 17, 2015 11:29
Show Gist options
  • Select an option

  • Save smockle/5602264 to your computer and use it in GitHub Desktop.

Select an option

Save smockle/5602264 to your computer and use it in GitHub Desktop.
Errors explains how to enable custom errors in Rails.
  1. Register your application by appending this to config/application.rb:

    config.exceptions_app = self.routes
    
  2. Add routes by appending this to config/routes.rb:

    match '/404', :to => 'errors#not_found'
    match '/422', :to => 'errors#server_error'
    match '/500', :to => 'errors#server_error'
    
  3. Add an ErrorsController and views by running:

    rails g controller Errors not_found server_error
    
  4. View custom error pages locally by setting this in config/development.rb

    config.consider_all_requests_local = false
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment