show error message for comment errors

This commit is contained in:
albert
2013-02-26 21:57:18 -08:00
parent e86dda1b50
commit 5bf22e9c67

View File

@@ -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