summaryrefslogtreecommitdiff
path: root/app/models/node.rb
diff options
context:
space:
mode:
authorhukl <hukl@berlin.ccc.de>2009-01-29 22:30:00 +0100
committerhukl <hukl@berlin.ccc.de>2009-01-29 22:30:00 +0100
commit7edc07cb016bebb9b6c06e105f88f595d5ad00c3 (patch)
tree4bb6e9ef4eb3d7f5ddb877d20bd2286e440f07c4 /app/models/node.rb
parentbe47a4bbeac59d85af16b5e83e10ff242628519d (diff)
added generation of unique names based on the position on the tree after adding a node as a children of another node
Diffstat (limited to 'app/models/node.rb')
-rw-r--r--app/models/node.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/node.rb b/app/models/node.rb
index 82183c9..e2ff973 100644
--- a/app/models/node.rb
+++ b/app/models/node.rb
@@ -1,3 +1,13 @@
1class Node < ActiveRecord::Base 1class Node < ActiveRecord::Base
2 acts_as_nested_set 2 acts_as_nested_set
3
4 # returns array with pages up to root excluding root
5 def path_to_root
6 parent.nil? && [slug] || parent.path_to_root.push(slug)
7 end
8
9 def update_unique_name
10 path = self.path_to_root[1..-1]
11 self.unique_name = path.join("/")
12 end
3end 13end