From c7d2d1b51ba07fbeabf7c7a0da000b47a692700b Mon Sep 17 00:00:00 2001 From: hukl Date: Mon, 7 Sep 2009 17:16:52 +0200 Subject: fixed a bug in update_unique_name --- app/models/node.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'app/models/node.rb') diff --git a/app/models/node.rb b/app/models/node.rb index 318c203..d4979ea 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -111,9 +111,13 @@ class Node < ActiveRecord::Base parent.nil? ? [slug] : parent.path_to_root.push(slug) end - def update_unique_name - path = self.path_to_root[1..-1] + def current_unique_name + path = path_to_root[1..-1] # excluding root self.unique_name = path.join("/") + end + + def update_unique_name + current_unique_name self.save end @@ -145,11 +149,8 @@ class Node < ActiveRecord::Base def check_for_changed_slug if parent and changed.include? "slug" - self.update_unique_name - - if tmp_descendants = descendants - tmp_descendants.each { |descendant| descendant.update_unique_name } - end + self.unique_name = current_unique_name + self.descendants.each { |descendant| descendant.update_unique_name } end end end -- cgit v1.3