Class: ThinkFeelDoEngine::LessonSlidesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/think_feel_do_engine/lesson_slides_controller.rb

Overview

Enables slide CRUD functionality.

Constant Summary

Constants inherited from ApplicationController

ApplicationController::CSRF_COOKIE_NAME, ApplicationController::CSRF_HEADER_NAME, ApplicationController::INACTIVE_MESSAGE, ApplicationController::ROOT_URI

Instance Method Summary collapse

Methods inherited from ApplicationController

#access_denied_resource_path, #after_sign_in_path_for, #after_sign_out_path_for

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/think_feel_do_engine/lesson_slides_controller.rb', line 16

def create
  authorize! :create, BitCore::Slide
  @slide = @lesson.build_slide(slide_params)

  if @slide.save
    redirect_to arm_lesson_path(@arm, @lesson),
                notice: "Successfully created slide for lesson"
  else
    flash.now[:alert] = @slide.errors.full_messages.join(", ")
    render :new
  end
end

#destroyObject



49
50
51
52
53
54
55
56
57
# File 'app/controllers/think_feel_do_engine/lesson_slides_controller.rb', line 49

def destroy
  authorize! :destroy, BitCore::Slide

  if @lesson.destroy_slide(@slide)
    redirect_to arm_lesson_path(@arm, @lesson), notice: "Slide deleted"
  else
    redirect_to arm_lesson_path(@arm, @lesson), alert: "There were errors."
  end
end

#editObject



33
34
35
# File 'app/controllers/think_feel_do_engine/lesson_slides_controller.rb', line 33

def edit
  authorize! :edit, BitCore::Slide
end

#newObject



11
12
13
14
# File 'app/controllers/think_feel_do_engine/lesson_slides_controller.rb', line 11

def new
  authorize! :new, BitCore::Slide
  @slide = @lesson.build_slide(slide_params)
end

#showObject



29
30
31
# File 'app/controllers/think_feel_do_engine/lesson_slides_controller.rb', line 29

def show
  authorize! :show, BitCore::Slide
end

#sortObject



59
60
61
62
63
64
65
66
67
68
# File 'app/controllers/think_feel_do_engine/lesson_slides_controller.rb', line 59

def sort
  authorize! :update, ContentModules::LessonModule
  if @lesson.sort(params[:slide])
    flash.now[:success] = "Reorder was successful."
    render nothing: true
  else
    flash.now[:alert] = @lesson.errors.full_messages.join(", ")
    render nothing: true
  end
end

#updateObject



37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/think_feel_do_engine/lesson_slides_controller.rb', line 37

def update
  authorize! :update, BitCore::Slide

  if @slide.update(slide_params)
    redirect_to arm_lesson_path(@arm, @lesson),
                notice: "Successfully updated slide for lesson"
  else
    flash.now[:alert] = @slide.errors.full_messages.join(", ")
    render :edit
  end
end