Comments are now moderated automatically unless moderation is enabled and show up below posts.
This commit is contained in:
parent
21dca99ddf
commit
4d1e364085
15 changed files with 85 additions and 36 deletions
|
@ -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?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue