Created
June 4, 2014 08:17
-
-
Save pawel2105/725d7e7631442ef636f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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