summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/helpers/link_helper.rb12
-rw-r--r--app/models/node.rb5
-rw-r--r--app/views/pages/index.html.erb5
3 files changed, 18 insertions, 4 deletions
diff --git a/app/helpers/link_helper.rb b/app/helpers/link_helper.rb
new file mode 100644
index 0000000..68586c1
--- /dev/null
+++ b/app/helpers/link_helper.rb
@@ -0,0 +1,12 @@
1module LinkHelper
2
3 def link_to_path path
4 url_for(
5 :controller => :content,
6 :action => :render_page,
7 :language => I18n.locale,
8 :page_path => path
9 )
10 end
11
12end \ No newline at end of file
diff --git a/app/models/node.rb b/app/models/node.rb
index a1d8af0..e08e228 100644
--- a/app/models/node.rb
+++ b/app/models/node.rb
@@ -33,6 +33,11 @@ class Node < ActiveRecord::Base
33 33
34 # Instance Methods 34 # Instance Methods
35 35
36 # returns an array with all parts of a unique_name rather than a string
37 def unique_path
38 unique_name.split("/") rescue unique_name
39 end
40
36 # returns array with pages up to root excluding root 41 # returns array with pages up to root excluding root
37 def path_to_root 42 def path_to_root
38 parent.nil? && [slug] || parent.path_to_root.push(slug) 43 parent.nil? && [slug] || parent.path_to_root.push(slug)
diff --git a/app/views/pages/index.html.erb b/app/views/pages/index.html.erb
index 41c8bae..f5918f0 100644
--- a/app/views/pages/index.html.erb
+++ b/app/views/pages/index.html.erb
@@ -13,10 +13,7 @@
13 <tr> 13 <tr>
14 <td><%=h page.node_id %></td> 14 <td><%=h page.node_id %></td>
15 <td><%=h page.title %></td> 15 <td><%=h page.title %></td>
16 <td><%=h page.abstract %></td> 16 <td><%= link_to 'Show', link_to_path(page.node.unique_path) %></td>
17 <td><%=h page.body %></td>
18 <td><%=h page.revision %></td>
19 <td><%= link_to 'Show', page %></td>
20 <td><%= link_to 'Edit', edit_page_path(page) %></td> 17 <td><%= link_to 'Edit', edit_page_path(page) %></td>
21 <td><%= link_to 'Destroy', page, :confirm => 'Are you sure?', :method => :delete %></td> 18 <td><%= link_to 'Destroy', page, :confirm => 'Are you sure?', :method => :delete %></td>
22 </tr> 19 </tr>