Class: FeatherCms::PagesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- FeatherCms::PagesController
- Defined in:
- app/controllers/feather_cms/pages_controller.rb
Instance Method Summary collapse
- #all_page ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #find_page ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #preview ⇒ Object
- #published ⇒ Object
- #update ⇒ Object
Instance Method Details
#all_page ⇒ Object
79 80 81 |
# File 'app/controllers/feather_cms/pages_controller.rb', line 79 def all_page @pages = Page.order(:name) end |
#create ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/feather_cms/pages_controller.rb', line 28 def create @page = Page.new(params[:page]) @page.name = @page.name.parameterize @page.status = 'draft' @page.template_type = 'html' if @page.save redirect_to pages_path else render :new end end |
#destroy ⇒ Object
57 58 59 60 |
# File 'app/controllers/feather_cms/pages_controller.rb', line 57 def destroy @page.destroy redirect_to pages_path end |
#edit ⇒ Object
23 24 25 26 |
# File 'app/controllers/feather_cms/pages_controller.rb', line 23 def edit @draft_page = Page.where(:name => @page.name, :status => 'draft').first @published_page = Page.where(:name => @page.name, :status => 'published').first end |
#find_page ⇒ Object
75 76 77 |
# File 'app/controllers/feather_cms/pages_controller.rb', line 75 def find_page @page = Page.find(params[:id]) end |
#index ⇒ Object
15 16 |
# File 'app/controllers/feather_cms/pages_controller.rb', line 15 def index end |
#new ⇒ Object
18 19 20 21 |
# File 'app/controllers/feather_cms/pages_controller.rb', line 18 def new @page = Page.new @page.status = 'draft' end |
#preview ⇒ Object
62 63 64 |
# File 'app/controllers/feather_cms/pages_controller.rb', line 62 def preview render :inline => @page.content.html_safe, :type => @page.template_type, :layout => @page.layout end |
#published ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'app/controllers/feather_cms/pages_controller.rb', line 66 def published @page = Page.where(:name => params[:name], :status => 'published').first if @page render :inline => @page.content, :type => @page.template_type, :layout => @page.layout else redirect_to '/404.html' end end |
#update ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/feather_cms/pages_controller.rb', line 42 def update status = params[:page].delete(:status) @page.attributes = params[:page] @page.name = @page.name.parameterize @page.status = status @page.template_type = 'html' if @page.save redirect_to pages_path else render :new end end |