Sha256: 3e59bf973f29a69251e47014faf14aaf0fb8988a3415a4405133ff8dc7028bc8
Contents?: true
Size: 1.52 KB
Versions: 2
Compression:
Stored size: 1.52 KB
Contents
class Comment < ActiveRecord::Base include Freeberry::Models::Comment using_access_control validates :content, :presence => true, :length => { :maximum => 500 } validates :commentable_type, :presence => true, :inclusion => { :in => %w( Post Article ) } validates :author_type, :inclusion => { :in => %w( User FreeberryAuth::Account ) }, :allow_blank => true with_options :if => :anonymous? do |anonymous| anonymous.validates :user_name, :length => { :maximum => 100 }, :presence => true, :format => { :with => /\A[^[:cntrl:]\\<>\/&]*\z/ } anonymous.validates :user_email, :length => { :within => 6..100 }, :presence => true, :format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i } end attr_accessible :user_name, :user_email, :content, :is_follow #after_create :send_notifiers auto_html_for :content do html_escape big_words :length => 80, :tag => "span" image youtube :width => 500, :height => 300 vimeo :width => 500, :height => 300 link :target => "_blank", :rel => "nofollow" simple_format sanitize end def anonymous? author.nil? end def siblings self.class.siblings_for(self) end protected def send_notifiers emails = [ commentable.user.try(:email) ] emails.concat(siblings.follows.select("user_email").map(&:user_email).uniq) emails.delete_if{ |email| email.blank? || email == user_email } emails.each { |email| Notifier.comment(email, self).deliver } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
freeberry-0.2.7 | lib/generators/freeberry/models/templates/models/comment.rb |
freeberry-0.2.6 | lib/generators/freeberry/models/templates/models/comment.rb |