Sha256: 26bb98e50a0b0e7180977727ead8c54b226b09e3f30a576ff56a83c66eb51b67
Contents?: true
Size: 943 Bytes
Versions: 54
Compression:
Stored size: 943 Bytes
Contents
module Tenon class Post < ActiveRecord::Base # Scopes, Attachments, etc. default_scope { order('publish_at DESC') } scope :posted, -> { where('publish_at <= ?', Time.now) } scope :for_archive, ->(year, month) { where(Post.for_archive_conditions(year, month)) } tenon_content :content, i18n: true has_history includes: [:content_tenon_content_rows] # Relationships has_and_belongs_to_many :post_categories, class_name: 'Tenon::PostCategory' belongs_to :user can_have_comments # Validations validates_presence_of :title def to_param "#{id}-#{title.parameterize}" end # previous and next posts for mobile post nav def next Post.posted.where('publish_at > ?', publish_at).last end def previous Post.posted.where('publish_at < ?', publish_at).first end def posted? publish_at.present? ? publish_at <= Time.now : false end end end
Version data entries
54 entries across 54 versions & 1 rubygems