Sha256: 1c4bc5daa9af2deb9bf8f6b2edb81aee68cf047dec3ab9b03de3d3db9b985034

Contents?: true

Size: 549 Bytes

Versions: 12

Compression:

Stored size: 549 Bytes

Contents

module Smithy
  class ContentBlockTemplate < ActiveRecord::Base
    belongs_to :content_block, :touch => true
    has_many :page_contents

    validates_presence_of :name
    validates_uniqueness_of :name, :scope => :content_block_id
    validates_presence_of :content

    after_save :touch_page_contents

    default_scope -> { order(:name) }

    def liquid_template
      @liquid_template ||= ::Liquid::Template.parse(self.content)
    end

    private
      def touch_page_contents
        self.page_contents.each(&:touch)
      end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
smithycms-0.6.2 app/models/smithy/content_block_template.rb
smithycms-0.6.1 app/models/smithy/content_block_template.rb
smithycms-0.5.2 app/models/smithy/content_block_template.rb
smithycms-0.6.0 app/models/smithy/content_block_template.rb
smithycms-0.5.1 app/models/smithy/content_block_template.rb
smithycms-0.5.0 app/models/smithy/content_block_template.rb
smithycms-0.4.5 app/models/smithy/content_block_template.rb
smithycms-0.4.4 app/models/smithy/content_block_template.rb
smithycms-0.4.3 app/models/smithy/content_block_template.rb
smithycms-0.4.2 app/models/smithy/content_block_template.rb
smithycms-0.4.1 app/models/smithy/content_block_template.rb
smithycms-0.4.0 app/models/smithy/content_block_template.rb