Sha256: 6321fd3fd97a34099c028f67b5ff845515650ac93d5968ccffb602b8701a299d
Contents?: true
Size: 908 Bytes
Versions: 6
Compression:
Stored size: 908 Bytes
Contents
module Virgo class Slideshow < ActiveRecord::Base validates :name, presence: true after_save :expire_site_key after_save :expire_containing_posts belongs_to :author, class_name: 'Virgo::User' has_many :slides, dependent: :destroy scope :search, ->(filters=nil) { filters ||= {} items = all if filters[:term].present? if filters[:term].to_i items = items.where("virgo_slideshows.name ILIKE :term_wildcard OR virgo_slideshows.id = :term", term_wildcard: "%#{filters[:term]}%", term: filters[:term].to_i) else items = items.where("virgo_slideshows.name ILIKE :term_wildcard", term_wildcard: "%#{filters[:term]}%") end end items } def containing_posts Post.containing_slideshow(self) end private def expire_containing_posts containing_posts.map &:touch end end end
Version data entries
6 entries across 6 versions & 1 rubygems