Skip to content

Commit

Permalink
Added more specific error/success messages when comments are posted
Browse files Browse the repository at this point in the history
  • Loading branch information
awagener authored and unixcharles committed Jul 10, 2010
1 parent 42a52f7 commit dab531a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
13 changes: 10 additions & 3 deletions app/controllers/blogs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
11 changes: 9 additions & 2 deletions app/views/blogs/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand Down

0 comments on commit dab531a

Please sign in to comment.