From 484bf69ead7a1f69c9047a25b3f63b9d6f875728 Mon Sep 17 00:00:00 2001 From: Urvashi Gupta Date: Wed, 7 Oct 2020 01:57:10 +0530 Subject: [PATCH] comment-error-msg (#8456) --- app/assets/javascripts/comment.js | 3 ++- app/controllers/comment_controller.rb | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/comment.js b/app/assets/javascripts/comment.js index 54c2e6d6f4..42e6b77c2a 100644 --- a/app/assets/javascripts/comment.js +++ b/app/assets/javascripts/comment.js @@ -23,7 +23,8 @@ if(!$(this).hasClass('bound-error')) { $(this).addClass('bound-error').bind('ajax:error', function(e,response){ - notyNotification('mint', 3000, 'success', 'topRight', 'Some error occured while adding comment'); + notyNotification('mint', 3000, 'error', 'topRight', 'Some error occured while adding comment'); + $(this).find('#text-input').prop('disabled',false); $(this).find('.control-group').addClass('has-error') $(this).find('.control-group .help-block ').remove() $(this).find('#text-input').val(''); diff --git a/app/controllers/comment_controller.rb b/app/controllers/comment_controller.rb index f8c9948c6f..8cb5e97799 100644 --- a/app/controllers/comment_controller.rb +++ b/app/controllers/comment_controller.rb @@ -51,8 +51,8 @@ def create end end rescue CommentError - flash[:error] = 'The comment could not be saved.' - render plain: 'failure' + flash.now[:error] = 'The comment could not be saved.' + render plain: 'failure', status: :bad_request end end