Sha256: 19b2e47b2f8c3a39c295429ac9c254b79d8f646d4be18779655a058f7dcde651
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
module PagesCms class Article < ActiveRecord::Base belongs_to :image validates :title, presence: true validates :content, presence: true validates :tags, presence: true def tags=(val) write_attribute(:tags, val.strip.gsub(/\s+/, '_').split(',') ) end def self.published self.where('archived != true AND draft != true') end def self.all_tags self.each do |article| end end def article_status if self.draft && !self.archived 'Draft' elsif self.archived && !self.draft 'Archived' elsif !self.draft && !self.archived 'Published' elsif self.draft && self.archived 'Archived' end end scope :search, -> (search) { where('content ILIKE ? OR tags @> ? OR title ILIKE ? ',"#{search}",'{' + search + '}',"#{search}") } scope :status, -> (status) do case status when 'Archived' where(archived: true) when 'Drafts' where(draft: true) when 'Published' where('archived != true AND draft != true') else all end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pages_cms-1.1.0 | app/models/pages_cms/article.rb |