Repository URL to install this package:
Version:
0.3.7 ▾
|
require 'neoteric-navigator'
require 'neoteric-archiver'
require 'friendly_id'
require 'acts-as-taggable-on'
module Neoteric
module BlogPost
def self.included(base)
base.table_name = 'blog_posts'
base.extend ClassMethods
base.extend ::FriendlyId
base.friendly_id :title, use: :slugged
base.send :include, ::Neoteric::Archiver
base.archive_fields :single => :pubdate,
:scope => :published
base.send :include, ::Neoteric::Navigator
base.navigate :scope => :published,
:field => :pubdate,
:order => 'pubdate DESC'
base.acts_as_taggable
base.attr_accessible :title, :body, :pubdate, :teaser, :tag_list, :drafted
base.validates :title, :body, :pubdate, :presence => true
end
module ClassMethods
def published
where('pubdate <= ? AND drafted IS NULL or drafted = ?', Date.today, false)
end
end
end
end