Class: Pageflow::StorylinesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  entry = DraftEntry.find(params[:entry_id])
  storyline = entry.storylines.build(storyline_params)

  authorize!(:create, storyline)
  verify_edit_lock!(entry.to_model)
  storyline.save

  respond_with(storyline)
end

#destroyObject



51
52
53
54
55
56
57
58
59
60
# File 'app/controllers/pageflow/storylines_controller.rb', line 51

def destroy
  storyline = Storyline.find(params[:id])

  authorize!(:destroy, storyline)
  verify_edit_lock!(storyline.entry)

  storyline.destroy

  respond_with(storyline)
end

#orderObject



39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/pageflow/storylines_controller.rb', line 39

def order
  entry = DraftEntry.find(params[:entry_id])

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

  head :no_content
end

#scaffoldObject



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

def scaffold
  entry = DraftEntry.find(params[:entry_id])
  storyline_scaffold = StorylineScaffold.build(entry, storyline_params, params.slice(:depth))

  authorize!(:create, storyline_scaffold.to_model)
  verify_edit_lock!(entry.to_model)
  storyline_scaffold.save!

  respond_with(storyline_scaffold)
end

#updateObject



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

def update
  storyline = Storyline.find(params[:id])

  authorize!(:update, storyline)
  verify_edit_lock!(storyline.entry)
  storyline.update(storyline_params)

  respond_with(storyline)
end