class Customize::InheritNode < ActiveRecord::Base self.table_name = "customize_inherit_nodes" belongs_to :parent_node, :class_name=>self.name, :foreign_key=> 'parent_id' has_many :children, :class_name=>self.name, :foreign_key=>'parent_id' after_destroy { |object| object.class.where("right > :right and node_type = :type", :right=>object.right, :type=>object.node_type).update_all("right = right -2") } end