summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/admin_controller.rb6
-rw-r--r--app/models/node.rb10
2 files changed, 13 insertions, 3 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 0446387..57f0d77 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -35,7 +35,11 @@ class AdminController < ApplicationController
35 end 35 end
36 36
37 def menu_search 37 def menu_search
38 @results = Node.search params[:search_term] 38 if params[:search_term] == "Root"
39 @results = [Node.root]
40 else
41 @results = Node.search params[:search_term]
42 end
39 43
40 respond_to do |format| 44 respond_to do |format|
41 format.html do 45 format.html do
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