Sha256: 21c251b72637d6c5709f79adeec614134767d64362c66a98071cbcb143b987aa
Contents?: true
Size: 969 Bytes
Versions: 1
Compression:
Stored size: 969 Bytes
Contents
require 'mongoid' class TaxonomyTerm include Mongoid::Document include Mongoid::Timestamps cache # cache all calls to the taxonomy terms, they don't change much field :label, type: String field :term_id, type: String field :term_type, :type => Hash, :default => {} key :term_id has_and_belongs_to_many :child_terms, :class_name => 'TaxonomyTerm', :inverse_of => :parent_term belongs_to :parent_term, :class_name => 'TaxonomyTerm', :inverse_of => :child_terms #validations validates_presence_of :term_id, :label validates_uniqueness_of :term_id scope :term_id_is, ->(term_id) { where(:term_id => term_id) } scope :parent_term_in, ->(parent_term_id) { where(:parent_term.in => parent_term_id)} scope :label_is, ->(label) {where(:label => label)} scope :fund_code_is, ->(fund_code) { where(:'term_type.FUND_CODE' => fund_code.gsub(/^0*/, ""))} def self.purge! TaxonomyTerm.destroy_all end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
daengine-0.2.19 | app/models/taxonomy_term.rb |