class InstitutionServiceCategory < ActiveRecord::Base
  attr_accessible :name, :institution_id

  # Associations
  belongs_to :institution
  has_many :institution_services, order: :name, dependent: :destroy

  # Validations
  validates :institution_id, :name, presence: true

  # Scopes
  scope :with_institution_services, includes(:institution_services).
    where('IFNULL(institution_services.active, 0) = 1').
    where('institution_services.id IS NOT NULL')
end
