Class: Pageflow::ChaptersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Pageflow::ChaptersController
- Defined in:
- app/controllers/pageflow/chapters_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/pageflow/chapters_controller.rb', line 7 def create storyline = Storyline.find(params[:storyline_id]) chapter = storyline.chapters.build(chapter_params) (:create, chapter) verify_edit_lock!(storyline.entry) chapter.save respond_with(chapter) end |
#destroy ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/controllers/pageflow/chapters_controller.rb', line 52 def destroy chapter = Chapter.find(params[:id]) (:destroy, chapter) verify_edit_lock!(chapter.entry) chapter.entry.snapshot(creator: current_user) chapter.destroy respond_with(chapter) end |
#order ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/pageflow/chapters_controller.rb', line 39 def order storyline = Storyline.find(params[:storyline_id]) entry = DraftEntry.new(storyline.entry) (:edit_outline, storyline.entry) verify_edit_lock!(storyline.entry) params.require(:ids).each_with_index do |id, index| entry.chapters.find(id).update(storyline_id: storyline.id, position: index) end head :no_content end |
#scaffold ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/pageflow/chapters_controller.rb', line 18 def scaffold storyline = Storyline.find(params[:storyline_id]) chapter_scaffold = ChapterScaffold.build(storyline, chapter_params, depth: 'page') (:create, chapter_scaffold.to_model) verify_edit_lock!(storyline.entry) chapter_scaffold.save! respond_with(chapter_scaffold) end |
#update ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/pageflow/chapters_controller.rb', line 29 def update chapter = Chapter.find(params[:id]) (:update, chapter) verify_edit_lock!(chapter.entry) chapter.update(chapter_params) respond_with(chapter) end |