Sha256: ceefaf9065a29df95c06b60d6919e4b5a6fc6d9ccf7d70c040a0f7a7a95643c8

Contents?: true

Size: 816 Bytes

Versions: 3

Compression:

Stored size: 816 Bytes

Contents

class Blog::Comment < ActiveRecord::Base
  
  self.table_name = '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

3 entries across 3 versions & 1 rubygems

Version Path
comfy_blog-1.1.1 app/models/blog/comment.rb
comfy_blog-1.1.0 app/models/blog/comment.rb
comfy_blog-1.0.0 app/models/blog/comment.rb