Class: ThinkFeelDoEngine::BitMaker::ContentProvidersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/think_feel_do_engine/bit_maker/content_providers_controller.rb

Overview

Enables Admins to create, update, and delete content providers Content providers display the unique views that participants As they traverse each tool each day

Constant Summary collapse

PROVIDER_NOT_FOUND =
"Unable to find Content Provider"

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, #raise_not_found!, #render_not_found

Instance Method Details

#createObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/think_feel_do_engine/bit_maker/content_providers_controller.rb', line 44

def create
  authorize! :create, BitCore::ContentProvider
  @content_provider = ContentProviderDecorator
                      .new(content_provider_params)

  if @content_provider.save
    redirect_to arm_bit_maker_content_provider_path(
      @arm, @content_provider
    ), notice: "ContentProvider was successfully created."
  else
    flash.now[:alert] = "Unable to save ContentProvider " +
                        model_errors
    render :new
  end
end

#destroyObject



75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'app/controllers/think_feel_do_engine/bit_maker/content_providers_controller.rb', line 75

def destroy
  authorize! :destroy, BitCore::ContentProvider
  @content_provider = find_content_provider

  if @content_provider.destroy
    redirect_to arm_bit_maker_content_providers_url(@arm),
                notice: "Content provider was successfully destroyed."
  else
    redirect_to arm_bit_maker_content_providers_url(@arm),
                alert: "Unable to delete ContentProvider " +
                       model_errors
  end
end

#editObject



39
40
41
42
# File 'app/controllers/think_feel_do_engine/bit_maker/content_providers_controller.rb', line 39

def edit
  authorize! :edit, BitCore::ContentProvider
  @content_provider = find_content_provider
end

#indexObject



15
16
17
18
# File 'app/controllers/think_feel_do_engine/bit_maker/content_providers_controller.rb', line 15

def index
  authorize! :index, BitCore::ContentProvider
  @content_providers = BitCore::ContentProvider.all
end

#newObject



30
31
32
33
34
35
36
37
# File 'app/controllers/think_feel_do_engine/bit_maker/content_providers_controller.rb', line 30

def new
  authorize! :new, BitCore::ContentProvider
  @content_provider = ContentProviderDecorator
                      .new(
                        bit_core_content_module_id:
                        params[:bit_core_content_module_id]
                      )
end

#showObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/think_feel_do_engine/bit_maker/content_providers_controller.rb', line 20

def show
  authorize! :show, BitCore::ContentProvider

  @content_provider = find_content_provider
  if @content_provider.is_a?(ContentProviderDecorator) &&
     @content_provider.source_content_id
    @slideshow = @content_provider.source_content
  end
end

#updateObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/controllers/think_feel_do_engine/bit_maker/content_providers_controller.rb', line 60

def update
  authorize! :update, BitCore::ContentProvider
  @content_provider = find_content_provider

  if @content_provider.update(content_provider_params)
    redirect_to arm_bit_maker_content_provider_path(
      @arm, @content_provider
    ), notice: "ContentProvider was successfully updated."
  else
    flash.now[:alert] = "Unable to save ContentProvider " +
                        model_errors
    render :edit
  end
end