Sha256: c8bc1e9450cb661dd5455757ad5c4f71c6cec2e4a2d11df2e1f1f9d48f75cf67

Contents?: true

Size: 663 Bytes

Versions: 3

Compression:

Stored size: 663 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(content_with_fixed_asset_links)
    end

    private
      def content_with_fixed_asset_links
        Smithy::AssetLink.fix(self.content)
      end

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

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
smithycms-0.5.99.3 app/models/smithy/content_block_template.rb
smithycms-0.5.99.2 app/models/smithy/content_block_template.rb
smithycms-0.5.99.1 app/models/smithy/content_block_template.rb