Class: Pageflow::PagesController Private

Inherits:
ApplicationController show all
Defined in:
app/controllers/pageflow/pages_controller.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#createObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/pageflow/pages_controller.rb', line 8

def create
  chapter = Chapter.find(params[:chapter_id])
  page = chapter.pages.build(page_params)

  authorize!(:create, page)
  verify_edit_lock!(page.chapter.entry)
  page.save

  respond_with(page)
end

#destroyObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/pageflow/pages_controller.rb', line 42

def destroy
  page = Page.find(params[:id])

  authorize!(:destroy, page)
  verify_edit_lock!(page.chapter.entry)
  page.chapter.entry.snapshot(creator: current_user)

  page.destroy

  respond_with(page)
end

#orderObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/pageflow/pages_controller.rb', line 29

def order
  chapter = Chapter.find(params[:chapter_id])
  entry = DraftEntry.new(chapter.entry)

  authorize!(:edit_outline, entry.to_model)
  verify_edit_lock!(chapter.entry)
  params.require(:ids).each_with_index do |id, index|
    entry.pages.find(id).update(chapter_id: chapter.id, position: index)
  end

  head :no_content
end

#updateObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
22
23
24
25
26
27
# File 'app/controllers/pageflow/pages_controller.rb', line 19

def update
  page = Page.find(params[:id])

  authorize!(:update, page)
  verify_edit_lock!(page.chapter.entry)
  page.update(page_params)

  respond_with(page)
end