class SubCategory < ActiveRecord::Base
  belongs_to :category
  has_many :items
  has_many :filter_criterias, as: :owner
  rails_admin do 
    object_label_method do
      :custom_subcat_name
    end
  end

  def custom_subcat_name
    return self.name if not self.category

    cat = self.category.name
    section = self.category.section.name

    "#{section} -> #{cat} -> #{self.name}"
  end
end
