Class: OCms::PagesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- OCms::PagesController
- Defined in:
- app/controllers/o_cms/pages_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/o_cms/pages_controller.rb', line 20 def create @page = Page.new(page_params) if @page.save flash[:notice] = "Page was saved successfully." redirect_to edit_page_path(@page) else flash.now[:alert] = "Error creating page. Please try again." @pages = Page.all render :new end end |
#destroy ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/o_cms/pages_controller.rb', line 52 def destroy @page = Page.find(params[:id]) if @page.destroy flash[:notice] = "\"#{@page.title}\" was deleted successfully." redirect_to action: :index @page.remove_subpage_relationships else flash.now[:alert] = "There was an error deleting the page." render :show end end |
#edit ⇒ Object
33 34 35 36 37 |
# File 'app/controllers/o_cms/pages_controller.rb', line 33 def edit @page = Page.find(params[:id]) @pages = Page.all_except(@page) @templates = Template.all end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/o_cms/pages_controller.rb', line 6 def index @pages = Page.page_parents end |
#new ⇒ Object
14 15 16 17 18 |
# File 'app/controllers/o_cms/pages_controller.rb', line 14 def new @page = Page.new @pages = Page.all @templates = Template.all end |
#show ⇒ Object
10 11 12 |
# File 'app/controllers/o_cms/pages_controller.rb', line 10 def show @page = Page.find(params[:id]) end |
#update ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/o_cms/pages_controller.rb', line 39 def update @page = Page.find(params[:id]) @page.assign_attributes(page_params) if @page.save flash[:notice] = "Page was updated successfully." redirect_to edit_page_path(@page) else flash.now[:alert] = "Error saving page. Please try again." render :edit end end |