Sha256: d08d7da64cff0733e839b2ea87b0173117aac9819e558610822eeb746e5a23e6

Contents?: true

Size: 822 Bytes

Versions: 2

Compression:

Stored size: 822 Bytes

Contents

require 'subj_models/concerns/comprising_external_id'

module SubjModels

  module Category

    def self.included(including_class)

      including_class.class_eval do

        include SubjModels::ComprisingExternalId

        has_many :nomenclatures

        belongs_to :image, class_name: "DocumentFile"
        belongs_to :image_big, class_name: "DocumentFile"  

        validates :name, presence: true
        #validates :slug_url, length: { minimum: 4, maximum: 50 }, uniqueness: true, presence: true

        scope :by_slug_url, -> slug_url { where(slug_url: slug_url) }
        scope :is_public, -> condition { where(is_public: condition) }
        scope :by_id, -> ids { where(id: ids) }
        scope :exclude_by_id, -> ids { where.not(id: ids) }

      end

    end

    def to_s
      name
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
subj_models-0.4.1 lib/subj_models/category.rb
subj_models-0.4 lib/subj_models/category.rb