Sha256: 8371f10df4b384d2647e79c95661cf544b2a3fcc74680e2648cbc37c742a0871
Contents?: true
Size: 728 Bytes
Versions: 3
Compression:
Stored size: 728 Bytes
Contents
module PagesCms class Article < ActiveRecord::Base include RenderContent has_one :image validates :title, presence: true validates :content, presence: true validates :tags, presence: true def tags=(val) write_attribute(:tags, val.split(',') ) 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('draft = ? AND archived = ?', false, false) else all end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pages_cms-0.0.3 | app/models/pages_cms/article.rb |
pages_cms-0.0.2 | app/models/pages_cms/article.rb |
pages_cms-0.0.1 | app/models/pages_cms/article.rb |