notebook/app/models/attribute_category.rb
2016-10-25 16:37:35 -07:00

34 lines
513 B
Ruby

class AttributeCategory < ActiveRecord::Base
validates :name, presence: true
belongs_to :user
has_many :attribute_fields
include HasAttributes
include Serendipitous::Concern
before_validation :ensure_name
def self.color
'amber'
end
def self.icon
'tab'
end
def self.content_name
'attribute_category'
end
def icon
self['icon'] || self.class.icon
end
private
def ensure_name
self.name ||= "#{label}-#{Time.now.to_i}".underscore.gsub(' ', '_')
end
end