Fix DoubleRenderError in update action and simplify display_errors - #700
Open
Solus90 wants to merge 1 commit into
Open
Fix DoubleRenderError in update action and simplify display_errors#700Solus90 wants to merge 1 commit into
Solus90 wants to merge 1 commit into
Conversation
In the action, when restroom validation fails, was called but execution continued to the unconditional below it, raising an AbstractController::DoubleRenderError. Added an explicit after to prevent this. In , the block had no block parameter and simply overwrote the same flash alert key on every iteration. Simplified to set the flash message once directly.
This file contains hidden or 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
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.
What
This PR fixes two bugs in
RestroomsController:Bug 1:
AbstractController::DoubleRenderErrorinupdateIn the
updateaction, when a restroom fails validation during an edit, the code called bothrender 'edit'and then fell through to the unconditionalredirect_to @restroombelow it. This raises anAbstractController::DoubleRenderErrorat runtime.Before:
After:
Bug 2: Redundant iteration in
display_errorsThe
display_errorshelper iterated over@restroom.errors.each dobut had no block parameter. On every iteration it simply overwrote the sameflash[:alert]key with the same value — a no-op loop that just sets the same string repeatedly and then discards it.Before:
After:
Impact
DoubleRenderErrorinstead of showing the edit form with an error message.