Class: Regulate::Admin::PagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Regulate::Admin::PagesController
- Includes:
- Helpers::ControllerHelpers
- Defined in:
- app/controllers/regulate/admin/pages_controller.rb
Overview
Standard CRUD Controller
Instance Method Summary collapse
-
#create ⇒ Object
POST route to create a new page.
-
#destroy ⇒ Object
DELETE method to destroy a page.
-
#edit ⇒ Object
GET skeleton method to get to an edit page.
-
#index ⇒ Object
GET skeleton method to show a list of pages.
-
#new ⇒ Object
GET method to show new Page form.
-
#show ⇒ Object
GET method to view a page Render the edit action.
-
#update ⇒ Object
PUT method to persist changes to a Page object.
Instance Method Details
#create ⇒ Object
POST route to create a new page
15 16 17 18 19 20 21 22 |
# File 'app/controllers/regulate/admin/pages_controller.rb', line 15 def create if Regulate::Page.create!(params[:page]) flash[:notice] = "Page created!" redirect_to regulate_admin_regulate_pages_path else render :action => :new end end |
#destroy ⇒ Object
DELETE method to destroy a page
44 45 46 47 48 |
# File 'app/controllers/regulate/admin/pages_controller.rb', line 44 def destroy @page.destroy flash[:notice] = "Page deleted." redirect_to regulate_admin_regulate_pages_path end |
#edit ⇒ Object
GET skeleton method to get to an edit page
25 |
# File 'app/controllers/regulate/admin/pages_controller.rb', line 25 def edit; end |
#index ⇒ Object
GET skeleton method to show a list of pages
51 52 53 |
# File 'app/controllers/regulate/admin/pages_controller.rb', line 51 def index @pages = Regulate::Page.find_all end |
#new ⇒ Object
GET method to show new Page form
39 40 41 |
# File 'app/controllers/regulate/admin/pages_controller.rb', line 39 def new @page = Regulate::Page.new end |
#show ⇒ Object
GET method to view a page Render the edit action
57 58 59 |
# File 'app/controllers/regulate/admin/pages_controller.rb', line 57 def show render :action => :edit end |
#update ⇒ Object
PUT method to persist changes to a Page object
28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/regulate/admin/pages_controller.rb', line 28 def update params[:page].delete(:view) if !@is_admin if @page.update_attributes(params[:page]) flash[:notice] = "Successfully updated #{params[:page][:title]}" redirect_to regulate_admin_regulate_pages_path else render :action => :edit end end |