class PagesController ApplicationControlle before_filter authorize def

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
class PagesController < ApplicationController
before_filter :authorize
def index
@pages = Page.find(:all, :order => 'position')
end
def show
@page = Page.find(params[:id])
end
def new
@page = Page.new
end
def create
@page = Page.new(params[:page])
if @page.save
flash[:notice] = "Successfully created page &ldquo;#{@page.title}&rdquo;."
redirect_to pages_path
else
render :action => 'new'
end
end
def edit
@page = Page.find(params[:id])
end
def update
@page = Page.find(params[:id])
if @page.update_attributes(params[:page])
flash[:notice] = "Successfully updated page &ldquo;#{@page.title}&rdquo;."
redirect_to pages_path
else
render :action => 'edit'
end
end
def destroy
@page = Page.find(params[:id])
tmp = @page.title
@page.destroy
flash[:notice] = "Successfully destroyed page &ldquo;#{tmp}&rdquo;."
redirect_to pages_url
end
end