From 5bf22e9c6735bdbb2a7e969fd1ae944d611380bd Mon Sep 17 00:00:00 2001 From: albert Date: Tue, 26 Feb 2013 21:57:18 -0800 Subject: [PATCH] show error message for comment errors --- app/controllers/comments_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index d01d1c478..52c114c2f 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -31,7 +31,11 @@ class CommentsController < ApplicationController @comment = Comment.create(params[:comment]) respond_with(@comment) do |format| format.html do - redirect_to post_path(@comment.post), :notice => "Comment posted" + if @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 end end end