Sha256: d75035a42f85f07a1f0ee8475aee9a67264e904472180ee5c11ae010c86649ec

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

module Panda
  module CMS
    class Block < ApplicationRecord
      self.table_name = "panda_cms_blocks"

      belongs_to :template, foreign_key: :panda_cms_template_id, class_name: "Panda::CMS::Template", inverse_of: :blocks, optional: true
      has_many :block_contents, foreign_key: :panda_cms_block_id, class_name: "Panda::CMS::BlockContent", inverse_of: :block

      validates :kind, presence: true
      validates :name, presence: true
      validates :key, presence: true, uniqueness: {scope: :panda_cms_template_id, case_sensitive: false}

      # Validation for presence on template intentionally skipped to allow global elements

      # NB: Commented out values are not yet implemented
      enum :kind, {
        plain_text: "plain_text",
        rich_text: "rich_text",
        iframe: "iframe",
        list: "list",
        code: "code"
        # image: "image",
        # video: "video",
        # audio: "audio",
        # file: "file",
        # iframe: "iframe",
        # quote: "quote",
        # list: "list"
        # table: "table",
        # form: "form"
      }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
panda-cms-0.7.3 app/models/panda/cms/block.rb
panda-cms-0.7.2 app/models/panda/cms/block.rb
panda-cms-0.7.0 app/models/panda/cms/block.rb