Sha256: 67b1be546c3ea6f7ccf0d15a0468b1459a20808b1ca48aaa302d5d28df93b1bc
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
## # Category 是分类。 module Unidom module Category class Category < ApplicationRecord self.table_name = 'unidom_categories' include Unidom::Common::Concerns::ModelExtension include Unidom::Category::Concerns::AsCategory include Unidom::Category::Concerns::AsAncestorCategory include Unidom::Category::Concerns::AsDescendantCategory validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit } validates :abbreviation, allow_blank: true, length: { in: 2..self.columns_hash['abbreviation'].limit } belongs_to :scheme, class_name: 'Unidom::Category::CategoryScheme', foreign_key: :scheme_id scope :scheme_is, ->(scheme) { where scheme_id: to_id(scheme) } scope :code_length_is, ->(length) { where 'LENGTH(code) = :code_length', code_length: length } scope :code_starting_with, ->(prefix) { where 'code LIKE :prefix_expression', prefix_expression: prefix+'%' } end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Category::Category' end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
unidom-category-2.0.1 | app/models/unidom/category/category.rb |