Sha256: 3cfc59de5c42dabc68b5a8af8aaafbc921aacd4d1291a77c98544649ae485aa5

Contents?: true

Size: 681 Bytes

Versions: 1

Compression:

Stored size: 681 Bytes

Contents

# frozen_string_literal: true

class Comfy::Cms::Category < ActiveRecord::Base
  self.table_name = 'comfy_cms_categories'

  # -- Relationships --------------------------------------------------------
  belongs_to :site
  has_many :categorizations,
           dependent: :destroy

  # -- Validations ----------------------------------------------------------
  validates :label,
            presence: true,
            uniqueness: { scope: %i[categorized_type site_id] }
  validates :categorized_type,
            presence:   true

  # -- Scopes ---------------------------------------------------------------
  scope :of_type, ->(type) {
    where(categorized_type: type)
  }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
comfortable_media_surfer-3.0.0 app/models/comfy/cms/category.rb