diff options
Diffstat (limited to 'app/models/node.rb')
| -rw-r--r-- | app/models/node.rb | 10 |
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 | ||
