aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/blog_comment.rb
diff options
context:
space:
mode:
authorPhilip Arndt <parndt@gmail.com>2010-08-30 11:14:46 +1200
committerPhilip Arndt <parndt@gmail.com>2010-08-30 11:14:46 +1200
commit4d1e364085c0de27d3ca58cc90eba9036744fc79 (patch)
tree2e0282206a95fc6fb91ec8aea38843543e886c85 /app/models/blog_comment.rb
parent21dca99ddf7eadb929bc9fe40a6b3f9fd90b2f41 (diff)
downloadrefinerycms-blog-4d1e364085c0de27d3ca58cc90eba9036744fc79.tar.gz
refinerycms-blog-4d1e364085c0de27d3ca58cc90eba9036744fc79.tar.bz2
refinerycms-blog-4d1e364085c0de27d3ca58cc90eba9036744fc79.zip
Comments are now moderated automatically unless moderation is enabled and show up below posts.
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?