Add a template for failed new diary comment validation #4634
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.
Here's a problem* that I came across when trying to create a controller for diary comments.
You write a comment for a diary entry, submit it and it fails the validation. Currently it's difficult to fail the validation, because empty comments are prevented client-side and it's difficult to type special characters that are disallowed. But let's suppose the validation failed. We have a branch for it:
openstreetmap-website/app/controllers/diary_entries_controller.rb
Line 154 in 50df5ee
It just renders the diary entry page again. You'll be looking at the top of the page, not where the comment form is. And the entered comment is reset:
openstreetmap-website/app/views/diary_entries/show.html.erb
Line 37 in 50df5ee
Here I'm showing a different page instead. It is similar to subscribe/unsubscribe pages and has a comment form that keeps the previously entered comment.
* The actual problem was that with a diary comments controller I'd have to render the show action of another controller.