summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-10-19 23:57:25 +0200
committerhukl <contact@smyck.org>2009-10-19 23:57:25 +0200
commit53d5b59744f43a94756190631a46fd58779b5fb9 (patch)
treeb28431e1348b4890b459be05cecb6613f3891319 /app/models
parentcb914e420c3f95b5f8e31a73ea19b7e53e4aa6c4 (diff)
changes for giving root a title
Diffstat (limited to 'app/models')
-rw-r--r--app/models/node.rb10
1 files changed, 8 insertions, 2 deletions
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
155 head ? head.title : draft.title 155 head ? head.title : draft.title
156 end 156 end
157 157
158 def update_unique_names?
159 !children.empty? && !children.first.path_to_root.include?(self.slug)
160 end
161
158 protected 162 protected
159 def lock_for! current_user 163 def lock_for! current_user
160 self.lock_owner = current_user 164 self.lock_owner = current_user
@@ -182,8 +186,10 @@ class Node < ActiveRecord::Base
182 # after_save callback which invokes update_unique_name on its children. 186 # after_save callback which invokes update_unique_name on its children.
183 # Hopefully until no childrens occur 187 # Hopefully until no childrens occur
184 def update_unique_names_of_children 188 def update_unique_names_of_children
185 self.descendants.each do |descendant| 189 unless root?
186 descendant.update_unique_name 190 self.descendants.each do |descendant|
191 descendant.update_unique_name
192 end
187 end 193 end
188 end 194 end
189 195