Sha256: d34593093d9dbed60fd2d6a2b85b5af3753ee4e9d6b507d6f7a5fe49bf588386

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

module PandaCms
  class Block < ApplicationRecord
    self.table_name = "panda_cms_blocks"

    belongs_to :template, foreign_key: :panda_cms_template_id, class_name: "PandaCms::Template", inverse_of: :blocks, optional: true
    has_many :block_contents, foreign_key: :panda_cms_block_id, class_name: "PandaCms::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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
panda_cms-0.6.3 app/models/panda_cms/block.rb
panda_cms-0.6.2 app/models/panda_cms/block.rb
panda_cms-0.6.1 app/models/panda_cms/block.rb
panda_cms-0.6.0 app/models/panda_cms/block.rb