Sha256: 5424a826b25838093c2e5781f28ce8251fbf975b7bbf5ae1e206fd4d500211d2
Contents?: true
Size: 969 Bytes
Versions: 4
Compression:
Stored size: 969 Bytes
Contents
class Cms::Snippet < ActiveRecord::Base set_table_name :cms_snippets has_revisions_for :content # -- Relationships -------------------------------------------------------- belongs_to :site # -- Callbacks ------------------------------------------------------------ after_save :clear_cached_page_content after_destroy :clear_cached_page_content # -- Validations ---------------------------------------------------------- validates :site_id, :presence => true validates :label, :presence => true validates :slug, :presence => true, :uniqueness => { :scope => :site_id }, :format => { :with => /^\w[a-z0-9_-]*$/i } protected # Note: This might be slow. We have no idea where the snippet is used, so # gotta reload every single page. Kinda sucks, but might be ok unless there # are hundreds of pages. def clear_cached_page_content site.pages.all.each{ |page| page.save! } end end
Version data entries
4 entries across 4 versions & 1 rubygems