public
Description: Rails Plugin - a RailsEngines-based CMS extension for any Rails project
Homepage: http://6brand.com
Clone URL: git://github.com/JackDanger/simple_pages.git
fully working

git-svn-id: http://svn.6brand.com/projects/plugins/simple_pages@311 
7491b73d-821b-0410-9297-ad1f6b5b4194
studioda (author)
Wed Feb 21 11:25:47 -0800 2007
commit  a41ba002dee9f35a06fcdfaa7e8fe0e19a158fbf
tree    d880ce3e8702c711918253b939268f1d8c40e113
parent  1992d6c483974daf97f13b58cba3035dcc095f61
...
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
...
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
 
49
50
51
52
 
53
54
55
56
0
@@ -1,48 +1,56 @@
0
 class SimplePagesController < ApplicationController
0
 
0
- before_filter :admin_required, :only => [:edit,
0
- :create,
0
- :update,
0
- :destroy]
0
+ before_filter :can_manage_pages?, :only => [:edit,
0
+ :create,
0
+ :update,
0
+ :destroy]
0
   before_filter :find_or_initialize, :except => :index
0
   before_filter :set_title, :except => :index
0
   
0
   def index
0
- @pages = SimplePage.find(:all)
0
+ @simple_pages = SimplePage.find(:all)
0
   end
0
   
0
   # render show
0
   
0
   def edit
0
- @page.revert_to(params[:version]) if params[:version] && @page.respond_to?(:revert_to)
0
+ @simple_page.revert_to(params[:version]) if params[:version] && @simple_page.respond_to?(:revert_to)
0
   end
0
   
0
   def create
0
- @page.update_attributes!(params[:page])
0
+ @simple_page.update_attributes!(params[:simple_page])
0
     flash[:success] = "Page successfully created"
0
- redirect_to :action => 'show', :id => @page
0
+ redirect_to simple_page_path(@simple_page)
0
   end
0
   
0
   def update
0
- @page.update_attributes!(params[:page])
0
+ @simple_page.update_attributes!(params[:simple_page])
0
     flash[:success] = "Page successfully modified"
0
- redirect_to :action => 'show', :id => @page
0
+ redirect_to simple_page_path(@simple_page)
0
   end
0
   
0
   def destroy
0
- @page.destroy
0
+ @simple_page.destroy
0
     flash[:success] = "Page successfully deleted"
0
     redirect_to :action => 'index'
0
   end
0
   
0
   protected
0
   
0
+ # this is where you customize permissions. Either set up an is_admin?
0
+ def can_manage_pages?
0
+ super
0
+ rescue
0
+ raise "You need to specify a method named 'can_manage_pages?' in your application.rb. Have it return true if the current user should be able to create/edit pages and false otherwise"
0
+ end
0
+ helper_method :can_manage_pages?
0
+
0
     def find_or_initialize
0
- @page = params[:id] ? SimplePage.find_by_filename(params[:id]) : SimplePage.new
0
+ @simple_page = params[:id] ? SimplePage.find_by_filename(params[:id]) : SimplePage.new
0
     end
0
     
0
     def set_title
0
- @title = @page.title if @page.respond_to?(:title)
0
+ @title = @simple_page.title if @simple_page.respond_to?(:title)
0
     end
0
     
0
     def rescue_action(exception)
...
9
10
11
12
13
14
15
...
9
10
11
 
12
13
14
0
@@ -9,7 +9,6 @@ class SimplePage < ActiveRecord::Base
0
   validates_uniqueness_of :filename, :title
0
   
0
   before_save :fix_filename
0
- before_save :process_content
0
   
0
   # Page#to_param is used to fill the :id portion of the request. This gives us pretty urls.
0
   def to_param

Comments

    No one has commented yet.