Sha256: 50a2df06e010b87a23ca15311b243d656a87ceb92b84d8ac5520b14dcbaef368

Contents?: true

Size: 924 Bytes

Versions: 3

Compression:

Stored size: 924 Bytes

Contents

module Cms
  class AbstractFileBlock < ActiveRecord::Base


    self.table_name = Namespacing.prefix("file_blocks")

    validates_presence_of :name

    scope :by_section, lambda { |section| {
        :include => {:attachment => :section_node},
        :conditions => ["#{SectionNode.table_name}.ancestry = ?", section.node.ancestry_path]}
    }

    # Return the parent section for this block.
    # @return [Cms::Section]
    def parent
      file.parent
    end

    def path
      file.url
    end

    def self.publishable?
      true
    end

    def set_attachment_path
      if @attachment_file_path && @attachment_file_path != attachment.file_path
        attachment.file_path = @attachment_file_path
      end
    end

    def set_attachment_section
      if @attachment_section_id && @attachment_section_id != attachment.section
        attachment.section_id = @attachment_section_id
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
browsercms-3.5.0.rc3 app/models/cms/abstract_file_block.rb
browsercms-3.5.0.rc2 app/models/cms/abstract_file_block.rb
browsercms-3.5.0.rc1 app/models/cms/abstract_file_block.rb