55 lines
1.0 KiB
Ruby
55 lines
1.0 KiB
Ruby
class Admin::PagesController < ApplicationController
|
|
|
|
layout "admin"
|
|
|
|
def index
|
|
@pages = Page.all( :conditions => { :parent_page_name => params[:parent] || "root" } )
|
|
end
|
|
|
|
def show
|
|
@page = Page.find(params[:id])
|
|
|
|
redirect_to "/#{@page.name}"
|
|
end
|
|
|
|
def new
|
|
@page = Page.new
|
|
@page.is_published = true
|
|
@page.parent_page_name = params[:parent_page_name]
|
|
end
|
|
|
|
def edit
|
|
@page = Page.find(params[:id])
|
|
end
|
|
|
|
def create
|
|
@page = Page.new(params[:page])
|
|
|
|
if @page.save
|
|
flash[:notice] = 'Page was successfully created.'
|
|
redirect_to admin_pages_url( :parent_page_name => @page.parent_page_name )
|
|
else
|
|
render :action => "new"
|
|
end
|
|
end
|
|
|
|
def update
|
|
@page = Page.find(params[:id])
|
|
|
|
if @page.update_attributes(params[:page])
|
|
flash[:notice] = 'Page was successfully updated.'
|
|
redirect_to admin_pages_url
|
|
else
|
|
render :action => "edit"
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@page = Page.find(params[:id])
|
|
@page.destroy
|
|
|
|
redirect_to admin_pages_url
|
|
end
|
|
|
|
end
|