Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added more specific error/success messages when comments are posted

  • Loading branch information...
commit dab531a7f869bb2154d5bd35f8deecd33304cafc 1 parent 42a52f7
@awagener awagener authored unixcharles committed
View
13 app/controllers/blogs_controller.rb
@@ -46,8 +46,14 @@ def comment
if Raptcha.valid?(params) || BlogSetting.enable_captcha == false
@comment.approved = true unless BlogSetting.manual_moderation
if @comment.save
- flash[:notice] = "Comment was posted successfully! Waiting for approval!"
- @message = @page[:successful_comment]
+ if BlogSetting.manual_moderation
+ flash[:notice] = "Thank you for your comment. It will appear once it has been approved by our moderators."
+ elsif BlogSetting.enable_approve_comment_by_email
+ flash[:notice] = "Thank you for your comment. You have been emailed to approve this comment before it will appear."
+ else
+ flash[:notice] = @page[:successful_comment]
+ end
+
if BlogSetting.enable_email_notification
begin
BlogMailer.deliver_notification(@comment, request)
@@ -65,7 +71,8 @@ def comment
@comment = @blog.comments.new
end
else
- @message = @page[:invalid_comment]
+ @comment.valid?
+ @comment.errors.add_to_base "Captcha is incorrect"
end
present(@page)
View
11 app/views/blogs/show.html.erb
@@ -18,9 +18,16 @@
<%= render :partial => 'comments' %>
<% if @blog.allow_comment %>
- <%= @message if @message %>
+
+ <!-- success message -->
+ <% flash.each do |key, value| %>
+ <div id="flash">
+ <%= value %>
+ </div>
+ <% end %>
+
<%= error_messages_for :comment, :header_message => "Whoops there was a small problem",
- :message => "The following problems need to be corrected:" %>
+ :message => "The following problems need to be corrected:" %>
<%= render :partial => 'form' %>
<% end %>
Please sign in to comment.
Something went wrong with that request. Please try again.