summaryrefslogtreecommitdiff
path: root/app/models/node.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/node.rb')
-rw-r--r--app/models/node.rb15
1 files changed, 8 insertions, 7 deletions
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
111 parent.nil? ? [slug] : parent.path_to_root.push(slug) 111 parent.nil? ? [slug] : parent.path_to_root.push(slug)
112 end 112 end
113 113
114 def update_unique_name 114 def current_unique_name
115 path = self.path_to_root[1..-1] 115 path = path_to_root[1..-1] # excluding root
116 self.unique_name = path.join("/") 116 self.unique_name = path.join("/")
117 end
118
119 def update_unique_name
120 current_unique_name
117 self.save 121 self.save
118 end 122 end
119 123
@@ -145,11 +149,8 @@ class Node < ActiveRecord::Base
145 149
146 def check_for_changed_slug 150 def check_for_changed_slug
147 if parent and changed.include? "slug" 151 if parent and changed.include? "slug"
148 self.update_unique_name 152 self.unique_name = current_unique_name
149 153 self.descendants.each { |descendant| descendant.update_unique_name }
150 if tmp_descendants = descendants
151 tmp_descendants.each { |descendant| descendant.update_unique_name }
152 end
153 end 154 end
154 end 155 end
155end 156end