engine/app/controllers/admin/pages_controller.rb

54 lines
954 B
Ruby
Raw Normal View History

2010-04-24 00:32:36 +00:00
class Admin::PagesController < Admin::BaseController
sections 'contents'
def index
2010-04-25 00:33:38 +00:00
@pages = Page.all
end
def new
@page = current_site.pages.build
end
def edit
@page = current_site.pages.find(params[:id])
end
def create
@page = current_site.pages.build(params[:page])
if @page.save
flash_success!
redirect_to edit_admin_page_url(@page)
else
flash_error!
render :action => 'new'
end
end
def update
@page = current_site.pages.find(params[:id])
if @page.update_attributes(params[:page])
flash_success!
redirect_to edit_admin_page_url(@page)
else
flash_error!
render :action => "edit"
end
end
def destroy
@page = current_site.pages.find(params[:id])
begin
@page.destroy
flash_success!
rescue Exception => e
flash[:error] = e.to_s
end
redirect_to admin_pages_url
2010-04-24 00:32:36 +00:00
end
end