2015-01-16 07:50:36 +01:00
|
|
|
class SubCategory < ActiveRecord::Base
|
|
|
|
|
belongs_to :category
|
2015-01-18 12:34:33 +01:00
|
|
|
has_many :items
|
2015-02-07 14:48:02 +01:00
|
|
|
has_many :filter_criterias, as: :owner
|
2015-02-12 21:37:23 +01:00
|
|
|
rails_admin do
|
|
|
|
|
object_label_method do
|
|
|
|
|
:custom_subcat_name
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def custom_subcat_name
|
2015-02-13 23:44:53 +01:00
|
|
|
return self.name if not self.category
|
|
|
|
|
|
2015-02-12 21:37:23 +01:00
|
|
|
cat = self.category.name
|
|
|
|
|
section = self.category.section.name
|
2015-02-13 23:44:53 +01:00
|
|
|
|
2015-02-12 21:37:23 +01:00
|
|
|
"#{section} -> #{cat} -> #{self.name}"
|
|
|
|
|
end
|
2015-01-16 07:50:36 +01:00
|
|
|
end
|