Sha256: ec1c325dad2b040658b55f2ed8a7e03be0f9c663c9484fe3313eb922124c85cd
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
# encoding: UTF-8 module Kublog class Post < ActiveRecord::Base extend FriendlyId include Notification::Email, Notification::Tweet, Notification::FbPost #Associations belongs_to :user, :class_name => Kublog.author_class belongs_to :category has_many :comments, :dependent => :destroy validates_presence_of :title, :body, :user validate :body_with_content #Special Attributes serialize :intended_for, Array friendly_id :title, :use => :slugged #Scopes default_scope order('kublog_posts.created_at DESC') def author user.to_s end def to_s title end # Public Access to the Post def url Engine.routes.url_helpers.quickie_url(self, :host => Kublog.default_url_options[:host]) end def related_posts self.category.posts.where('id != ?', self.id) unless self.category.nil? end private def body_with_content errors.add(:body, :blank) if blank_body? end # Weird regex identifies generated blank chars def blank_body? Sanitize.clean(self.body).gsub(/[ | ]/, '').blank? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kublog-0.0.1.1 | app/models/kublog/post.rb |