Sha256: 70f2a4851e8054b7b17ebb763d7436459d0a3ec1a92a9f7a292da3c9082f999c
Contents?: true
Size: 890 Bytes
Versions: 36
Compression:
Stored size: 890 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("slideshows.name ILIKE :term_wildcard OR slideshows.id = :term", term_wildcard: "%#{filters[:term]}%", term: filters[:term].to_i) else items = items.where("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
36 entries across 36 versions & 1 rubygems