Sha256: 8ebdf0e21d8c992661d270f462e028f5a4825880497c2cb38b6ec77dc4985abc
Contents?: true
Size: 719 Bytes
Versions: 4
Compression:
Stored size: 719 Bytes
Contents
class TaxonomyItem < ActiveRecord::Base belongs_to :parent, foreign_key: :parent_id, class_name: TaxonomyItem, required: false scope :categorized, -> { where.not(category: nil) } DEPTHS = { provider_types: 1, specialties: 2, sub_specialties: 3 }.freeze class << self def provider_types TaxonomyItem.where(depth: DEPTHS[:provider_types]) end def specialties TaxonomyItem.where(depth: DEPTHS[:specialties]) end def sub_specialties TaxonomyItem.where(depth: DEPTHS[:sub_specialties]) end def search_by_name(query) sql = TaxonomyItem.all sql = sql.where('name ILIKE ?', "%#{query}%") if query.present? sql end end end
Version data entries
4 entries across 4 versions & 1 rubygems