Class: Locomotive::PagesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/locomotive/pages_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


20
21
22
23
24
# File 'app/controllers/locomotive/pages_controller.rb', line 20

def create
  authorize Page
  @page = service.create(page_params)
  respond_with @page, location: -> { edit_content_path(@page) }
end

#destroyObject


38
39
40
41
42
# File 'app/controllers/locomotive/pages_controller.rb', line 38

def destroy
  authorize @page
  service.destroy(@page)
  respond_with @page, location: edit_content_path(current_site.pages.root.first)
end

#editObject


26
27
28
29
30
# File 'app/controllers/locomotive/pages_controller.rb', line 26

def edit
  authorize @page
  @page.find_layout
  respond_with @page
end

#newObject


14
15
16
17
18
# File 'app/controllers/locomotive/pages_controller.rb', line 14

def new
  authorize Page
  @page = current_site.pages.build
  respond_with @page
end

#sortObject


44
45
46
47
48
# File 'app/controllers/locomotive/pages_controller.rb', line 44

def sort
  authorize @page, :update?
  service.sort(@page, params.require(:children))
  respond_with @page, location: edit_page_path(current_site, @page)
end

#updateObject


32
33
34
35
36
# File 'app/controllers/locomotive/pages_controller.rb', line 32

def update
  authorize @page
  service.update(@page, page_params)
  respond_with @page, location: edit_page_path(current_site, @page)
end