lib/active_record/acts/category.rb
# Assigns a position integer after creation of a category
Assigns a position integer after creation of a category
Assigns a position integer after creation of a category
def assign_position
          if read_attribute(parent_id_column).nil?
            self.write_attribute(position_column, self.class.roots.size + 1)
          else
            self.write_attribute(position_column, self.class.find(:all, :conditions => ["#{parent_id_column} = ?", self.read_attribute(parent_id_column)]).size + 1)
          end
        end
def assign_position if read_attribute ( parent_id_column ) . nil? self . write_attribute ( position_column , self . class . roots . size + 1 ) else self . write_attribute ( position_column , self . class . find ( :all , :conditions => [ "#{parent_id_column} = ?" , self . read_attribute ( parent_id_column ) ] ) . size + 1 ) end end
Assigns a position integer after creation of a category
Assigns a position integer after creation of a category
# Position for new nodes is (number of siblings + 1), but only for new categories