Class: Admin::PagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Admin::PagesController
- Defined in:
- app/controllers/admin/pages_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/admin/pages_controller.rb', line 21 def create @page = Effective::Page.new(page_params) @page_title = 'New Page' if @page.save if params[:commit] == 'Save and Edit Content' redirect_to effective_regions.edit_path(effective_pages.page_path(@page), :exit => effective_pages.edit_admin_page_path(@page)) elsif params[:commit] == 'Save and Add New' flash[:success] = 'Successfully created page' redirect_to effective_pages.new_admin_page_path elsif params[:commit] == 'Save and View' redirect_to effective_pages.page_path(@page) else flash[:success] = 'Successfully created page' redirect_to effective_pages.edit_admin_page_path(@page) end else flash.now[:danger] = 'Unable to create page' render :action => :new end end |
#destroy ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'app/controllers/admin/pages_controller.rb', line 87 def destroy @page = Effective::Page.find(params[:id]) if @page.destroy flash[:success] = 'Successfully deleted page' else flash[:danger] = 'Unable to delete page' end redirect_to effective_pages.admin_pages_path end |
#edit ⇒ Object
45 46 47 48 49 50 |
# File 'app/controllers/admin/pages_controller.rb', line 45 def edit @page = Effective::Page.find(params[:id]) @page_title = 'Edit Page' end |
#index ⇒ Object
7 8 9 10 11 12 |
# File 'app/controllers/admin/pages_controller.rb', line 7 def index @datatable = EffectivePagesDatatable.new(self) @page_title = 'Pages' end |
#new ⇒ Object
14 15 16 17 18 19 |
# File 'app/controllers/admin/pages_controller.rb', line 14 def new @page = Effective::Page.new() @page_title = 'New Page' end |
#update ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'app/controllers/admin/pages_controller.rb', line 52 def update @page = Effective::Page.find(params[:id]) @page_title = 'Edit Page' if @page.update_attributes(page_params) if params[:commit] == 'Save and Edit Content' redirect_to effective_regions.edit_path(effective_pages.page_path(@page), :exit => effective_pages.edit_admin_page_path(@page)) elsif params[:commit] == 'Save and Add New' flash[:success] = 'Successfully updated page' redirect_to effective_pages.new_admin_page_path elsif params[:commit] == 'Save and View' redirect_to effective_pages.page_path(@page) elsif params[:commit] == 'Duplicate' begin page = @page.duplicate! flash[:success] = 'Successfully saved and duplicated page.' flash[:info] = "You are now editting the duplicated page. This new page has been created as a Draft." rescue => e flash.delete(:success) flash[:danger] = "Unable to duplicate page: #{e.}" end redirect_to effective_pages.edit_admin_page_path(page || @page) else flash[:success] = 'Successfully updated page' redirect_to effective_pages.edit_admin_page_path(@page) end else flash.now[:danger] = 'Unable to update page' render :action => :edit end end |