Skip to content

Instantly share code, notes, and snippets.

@pawel2105
Created June 4, 2014 08:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pawel2105/725d7e7631442ef636f9 to your computer and use it in GitHub Desktop.
Save pawel2105/725d7e7631442ef636f9 to your computer and use it in GitHub Desktop.
class ErrorsController < ApplicationController
def not_found
# Will render the app/views/errors/not_found.html.erb template
def not_found
respond_to do |format|
format.html { render template: 'errors/not_found', layout: 'layouts/application', status: 404 }
# Below is to ensure rails doesn't 500 when someone requests /blahblahblah.js or any other non-html format.
format.all { render nothing: true, status: 404 }
end
end
end
def error
render template: 'views/errors/error', layout: 'layouts/application', status: 500
# Will render the app/views/errors/error.html.erb template
end
end
# added as the last routes:
get '404' => 'errors#not_found'
get '500' => 'errors#error'
get '*a' => 'errors#not_found'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment