2015-01-18 10:24:15 +01:00
|
|
|
class Category < ActiveRecord::Base
|
|
|
|
|
has_many :sub_categories
|
2015-02-07 14:48:02 +01:00
|
|
|
has_many :filter_criterias, as: :owner
|
2015-01-18 10:24:15 +01:00
|
|
|
belongs_to :section
|
2015-02-13 23:44:53 +01:00
|
|
|
|
|
|
|
|
rails_admin do
|
|
|
|
|
object_label_method do
|
|
|
|
|
:custom_cat_name
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def custom_cat_name
|
|
|
|
|
return self.name if not self.section
|
|
|
|
|
|
|
|
|
|
section = self.section.name
|
|
|
|
|
"#{section} -> #{self.name}"
|
|
|
|
|
end
|
|
|
|
|
|
2015-01-18 10:24:15 +01:00
|
|
|
end
|