-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use custom error pages #1921
Merged
Merged
Use custom error pages #1921
Conversation
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
najclark
approved these changes
Jun 21, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, confirmed behavior works as expected
6 tasks
NicholasMy
pushed a commit
to UB-CSE-IT/Autolab
that referenced
this pull request
Jan 3, 2024
* Use custom error pages * Revert config.consider_all_requests_local * Update tests * Render instead of redirect * Remove unnecessary error routes * Delete 404 and 500 files (cherry picked from commit b8831e3)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Summary generated by Reviewpad on 24 Jun 23 16:20 UTC
This pull request includes changes to multiple files, which involve removing
rescue_from
blocks forActionView::MissingTemplate
exceptions, adding custom error pages using newerror_404
anderror_500
methods, changing authorization levels for some controller actions, modifying before and after action settings, rearranging some skip_before_action statements, and adding new configurations to use custom routes for error pages in the development and production environments. In addition, some unnecessaryget
routes were removed and new routes usingget
were added. Finally, some methods were added and removed from certain files such ashome_controller_spec.rb
,admins_controller.rb
, andscoreboards_controller.rb
.Description
rescue_from ActionView::MissingTemplate
since we haverescue_from Exception, with: :render_error
underapplication_controller.rb
error_500
method tohome_controller
for routing purposeserror.html.erb
toerror_500.html.erb
/404
and/500
config.exceptions_app = self.routes
to environments, so thatroutes.rb
is used for404
and500
errorsrender
instead ofredirect_to
inset_course
so that the url is preservedReferences
Motivation and Context
Currently, 404 errors are implicitly handled by Rails rendering the
404.html
page. Not only does this look bad because it doesn't include the layout, but also assets (favicon, image) do not properly load because they use absolute paths.This PR shifts towards using the existing
error_404
error page that was previously used forMissingTemplate
errors.Closes #682
How Has This Been Tested?
Tested using docker compose install (checkout this PR in the autolab subdirectory and rebuild). It'll help to add a
throw Exception
on some route for testing later, e.g.assessments_controller#show
.Note, this PR changes
production.rb.template
by adding the lineconfig.exceptions_app = self.routes
. However, this doesn't apply to existing instances of Autolab.Below is a comparison of the various error pages with and without this additional line. Basically, the only difference is that 404 errors (outside of controllers that use
set_course
) work properlyCurrently on Autolab prod / nightly
Invalid course name: e.g. {domain}/courses/dummy/assessments
Invalid page: e.g. {domain}/a/b
Exception
(Not tested, but should be the same as the following)
This PR: Before adding
config.exceptions_app = self.routes
Invalid course name: e.g. {domain}/courses/dummy/assessments
Invalid page: e.g. {domain}/a/b
Exception: on the page you added the Exception to
This PR: After adding
config.exceptions_app = self.routes
Invalid course name: e.g. {domain}/courses/dummy/assessments
Invalid page: e.g. {domain}/a/b
Exception: on the page you added the Exception to
Types of changes
Checklist:
overcommit --install && overcommit --sign
to use pre-commit hook for linting