From 83b96b4f3fb6f9091d6f2d0ce80653083c91d38d Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 18 Apr 2018 23:58:35 -0500 Subject: [PATCH] Fix #3652: URL addons stripped when comments are created/edited. --- app/controllers/comments_controller.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index c29cf1977..3c47bf13b 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -29,15 +29,10 @@ class CommentsController < ApplicationController def create @comment = Comment.create(comment_params(:create)) + flash[:notice] = @comment.valid? ? "Comment posted" : @comment.errors.full_messages.join("; ") respond_with(@comment) do |format| format.html do - if @comment.post.nil? - redirect_to comments_path, notice: @comment.errors.full_messages.join("; ") - elsif @comment.errors.any? - redirect_to post_path(@comment.post), :notice => @comment.errors.full_messages.join("; ") - else - redirect_to post_path(@comment.post), :notice => "Comment posted" - end + redirect_back fallback_location: (@comment.post || comments_path) end end end