Redirect /pages/id to /wiki/permalink

This commit is contained in:
Benjamin Meichsner 2009-09-28 15:31:20 +02:00
parent eca24d30f2
commit 7c192bbad3
6 changed files with 18 additions and 18 deletions

View file

@ -11,7 +11,17 @@ class PagesController < ApplicationController
end
def show
@page = Page.find_by_permalink(params[:permalink])
if params[:permalink]
@page = Page.find_by_permalink(params[:permalink])
elsif params[:id]
page = Page.find_by_id(params[:id])
if page.nil?
flash[:error] = "Seite existiert nicht!"
redirect_to all_pages_path and return
else
redirect_to wiki_page_path(page.permalink) and return
end
end
if @page.nil?
redirect_to new_page_path(:title => params[:permalink])

View file

@ -6,7 +6,9 @@
%h1 Alle Wikiseiten
%p= link_to "Neue Seite anlegen", new_page_path
#sidebar
#sidebar-links= link_to "Neue Seite anlegen", new_page_path
%table
%tr

View file

@ -14,7 +14,7 @@
= @page.title
#sidebar
#page-versions
#sidebar-links
= link_to "Bearbeiten", edit_page_path(@page)
= link_to_function "Versionen (#{@page.versions.count})", "Element.toggle('versions')"
- unless @page.children.empty?