Sha256: 70fecf604d43ecb00603174196190932f2721623c41142bfc6d5adda291ebe69
Contents?: true
Size: 705 Bytes
Versions: 8
Compression:
Stored size: 705 Bytes
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.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
8 entries across 8 versions & 1 rubygems