aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/blog_comment.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/blog_comment.rb')
-rw-r--r--app/models/blog_comment.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb
index cc890fa..c115aef 100644
--- a/app/models/blog_comment.rb
+++ b/app/models/blog_comment.rb
@@ -2,7 +2,7 @@ class BlogComment < ActiveRecord::Base
filters_spam :author_field => :name,
:email_field => :email,
- :message_field => :message
+ :message_field => :body
belongs_to :post, :class_name => 'BlogPost'
@@ -18,6 +18,12 @@ class BlogComment < ActiveRecord::Base
named_scope :approved, :conditions => {:state => 'approved'}
named_scope :rejected, :conditions => {:state => 'rejected'}
+ before_create do |comment|
+ unless BlogComment::Moderation.enabled?
+ comment.state = comment.spam? ? 'rejected' : 'approved'
+ end
+ end
+
module Moderation
class << self
def enabled?