module Banyan class Category < ActiveRecord::Base set_table_name 'banyan_categories' acts_as_nested_set translates :name has_many :categorizations, :class_name => 'Banyan::Categorization', :dependent => :destroy has_and_belongs_to_many :category_groups, :class_name => 'Banyan::CategoryGroup', :join_table => 'banyan_categories_category_groups', :include => :translations validates_presence_of :name attr_accessible :name, :tag before_save :set_tag, :unless => :tag? private def set_tag self.tag = name end end end