From 53d5b59744f43a94756190631a46fd58779b5fb9 Mon Sep 17 00:00:00 2001 From: hukl Date: Mon, 19 Oct 2009 23:57:25 +0200 Subject: changes for giving root a title --- app/models/node.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'app/models/node.rb') diff --git a/app/models/node.rb b/app/models/node.rb index 88a4d68..db484f9 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -155,6 +155,10 @@ class Node < ActiveRecord::Base head ? head.title : draft.title end + def update_unique_names? + !children.empty? && !children.first.path_to_root.include?(self.slug) + end + protected def lock_for! current_user self.lock_owner = current_user @@ -182,8 +186,10 @@ class Node < ActiveRecord::Base # after_save callback which invokes update_unique_name on its children. # Hopefully until no childrens occur def update_unique_names_of_children - self.descendants.each do |descendant| - descendant.update_unique_name + unless root? + self.descendants.each do |descendant| + descendant.update_unique_name + end end end -- cgit v1.3