Sha256: dfc1bb1a77c3264d7624f707bdb63fa6a087c8b9bf293b4139c292b193f1a9d6

Contents?: true

Size: 1.49 KB

Versions: 16

Compression:

Stored size: 1.49 KB

Contents

# Note: fragment caching is used during rendering.  The cache key is based
# on both the model and the current locale (because each model supports
# multiple translations).  The cache will be busted automatically since
# the updated_at attribute will be updated on save.
#------------------------------------------------------------------------------
class CmsSnippet < ActiveRecord::Base
  class Translation < ::Globalize::ActiveRecord::Translation
    has_paper_trail
  end

  # --- FriendlyId
  extend FriendlyId
  include DmCore::Concerns::FriendlyId

  default_scope         { where(account_id: Account.current.id) }
  
  # --- globalize (don't use versioning: true, translations erased when updating regular model data.  Maybe fixed in github version)
  translates            :content, :fallbacks_for_empty_translations => true
  globalize_accessors   :locales => DmCore::Language.language_array

  # --- versioning - skip anything translated
  has_paper_trail       :skip => :content
  
  # --- validations 
  validates_presence_of :itemtype, :slug
  validates_length_of   :itemtype,    :maximum => 30
  validates             :content, liquid: { :locales => true }, presence_default_locale: true

  # --- content types supported
  CONTENT_TYPES = [ 'Markdown', 'Textile', 'HTML' ]

  #------------------------------------------------------------------------------
  def is_published?
    published
  end
  
  #------------------------------------------------------------------------------
  def to_liquid
    {}
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
dm_cms-4.2.3.10 app/models/cms_snippet.rb
dm_cms-4.2.3.9 app/models/cms_snippet.rb
dm_cms-4.2.3.8 app/models/cms_snippet.rb
dm_cms-4.2.3.7 app/models/cms_snippet.rb
dm_cms-4.2.3.6 app/models/cms_snippet.rb
dm_cms-4.2.3.5 app/models/cms_snippet.rb
dm_cms-4.2.3.4 app/models/cms_snippet.rb
dm_cms-4.2.3.3 app/models/cms_snippet.rb
dm_cms-4.2.3.2 app/models/cms_snippet.rb
dm_cms-4.2.3.1 app/models/cms_snippet.rb
dm_cms-4.2.3 app/models/cms_snippet.rb
dm_cms-4.2.2.3 app/models/cms_snippet.rb
dm_cms-4.2.2.2 app/models/cms_snippet.rb
dm_cms-4.2.2.1 app/models/cms_snippet.rb
dm_cms-4.2.2 app/models/cms_snippet.rb
dm_cms-4.2.1.5 app/models/cms_snippet.rb