Sha256: 9ccca7698ac342c35b9736fe8639765fb02928d0bd36d187ea9c764a88ae2bb8

Contents?: true

Size: 829 Bytes

Versions: 4

Compression:

Stored size: 829 Bytes

Contents

class Comfy::Blog::Comment < ActiveRecord::Base
  
  self.table_name = 'comfy_blog_comments'
  
  # -- Relationships --------------------------------------------------------
  belongs_to :post
  
  # -- Callbacks ------------------------------------------------------------
  before_create :set_is_published
    
  # -- Validations ----------------------------------------------------------
  validates :post_id, :content, :author, :email, 
    :presence => true
  validates :email,
    :format => { :with => /\A([\w.%-+]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i }
    
  # -- Scopes ---------------------------------------------------------------
  scope :published, -> {
    where(:is_published => true)
  }
  
protected
  
  def set_is_published
    self.is_published = ComfyBlog.config.auto_publish_comments
    return
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
comfy_blog-1.12.3 app/models/comfy/blog/comment.rb
comfy_blog-1.12.2 app/models/comfy/blog/comment.rb
comfy_blog-1.12.1 app/models/comfy/blog/comment.rb
comfy_blog-1.12.0 app/models/comfy/blog/comment.rb