Class: Regulate::Admin::PagesController

Inherits:
ApplicationController
  • Object
show all
Includes:
Helpers::ControllerHelpers
Defined in:
app/controllers/regulate/admin/pages_controller.rb

Overview

Standard CRUD Controller

Instance Method Summary collapse

Instance Method Details

#createObject

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

#destroyObject

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

#editObject

GET skeleton method to get to an edit page



25
# File 'app/controllers/regulate/admin/pages_controller.rb', line 25

def edit; end

#indexObject

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

#newObject

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

#showObject

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

#updateObject

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