Orbit/app/controllers/admin/pages_controller.rb

51 lines
1010 B
Ruby
Raw Normal View History

class Admin::PagesController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :find_parent_item
def show
#TODO
end
def new
@page = Page.new
2009-05-22 06:43:52 +00:00
@page.is_published = true
2010-01-18 07:52:52 +00:00
@page.parent_name = @parent_item.name
end
def edit
@page = Page.find(params[:id])
end
def create
@page = Page.new(params[:page])
2010-01-04 09:49:55 +00:00
if @page.save
flash[:notice] = 'Page was successfully created.'
2010-01-18 07:52:52 +00:00
redirect_to admin_items_url( :parent_name => @page.parent_name )
2010-01-04 09:49:55 +00:00
else
render :action => "new"
end
end
def update
@page = Page.find(params[:id])
2010-01-04 09:49:55 +00:00
if @page.update_attributes(params[:page])
flash[:notice] = 'Page was successfully updated.'
2010-01-18 07:52:52 +00:00
redirect_to admin_items_url( :parent_name => @page.parent_name )
2010-01-04 09:49:55 +00:00
else
render :action => "edit"
end
end
def destroy
@page = Page.find(params[:id])
@page.destroy
2010-01-18 07:52:52 +00:00
redirect_to admin_items_url( :parent_name => @page.parent_name )
end
2010-01-04 09:49:55 +00:00
end