Class: ThinkFeelDoDashboard::ArmsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/think_feel_do_dashboard/arms_controller.rb

Overview

Allows for the creation, updating, and deletion of arms

Instance Method Summary collapse

Instance Method Details

#createObject

POST /think_feel_do_dashboard/arms



15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/think_feel_do_dashboard/arms_controller.rb', line 15

def create
  authorize! :create, Arm
  @arm = Arm.new(arm_params)
  if @arm.save
    redirect_to @arm,
                notice: "Arm was successfully created."
  else
    render :new
  end
end

#destroyObject

DELETE /think_feel_do_dashboard/arms/1



59
60
61
62
63
64
65
# File 'app/controllers/think_feel_do_dashboard/arms_controller.rb', line 59

def destroy
  @arm = Arm.find(params[:id])
  authorize! :destroy, @arm
  redirect_to arm_path(@arm),
              notice: "You do not have privileges to delete an arm. "\
              "Please contact the site administrator to remove this arm."
end

#editObject

GET /think_feel_do_dashboard/arms/1/edit



40
41
42
43
# File 'app/controllers/think_feel_do_dashboard/arms_controller.rb', line 40

def edit
  @arm = Arm.find(params[:id])
  authorize! :edit, @arm
end

#indexObject

GET /think_feel_do_dashboard/arms



9
10
11
12
# File 'app/controllers/think_feel_do_dashboard/arms_controller.rb', line 9

def index
  authorize! :index, Arm
  @arms = Arm.includes(:groups)
end

#newObject

GET /think_feel_do_dashboard/arms/new



27
28
29
30
# File 'app/controllers/think_feel_do_dashboard/arms_controller.rb', line 27

def new
  authorize! :new, Arm
  @arm = Arm.new
end

#showObject

GET /think_feel_do_dashboard/arms/1



33
34
35
36
37
# File 'app/controllers/think_feel_do_dashboard/arms_controller.rb', line 33

def show
  @arm = Arm.find(params[:id])
  authorize! :show, @arm
  @lesson = @arm.bit_core_tools.find_by_type("Tools::Learn")
end

#updateObject

PATCH/PUT /think_feel_do_dashboard/arms/1



46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/think_feel_do_dashboard/arms_controller.rb', line 46

def update
  @arm = Arm.find(params[:id])
  authorize! :update, @arm
  if @arm.update(arm_params)
    redirect_to arm_path(@arm),
                notice: "Arm was successfully updated.",
                only: true
  else
    render :edit
  end
end