Class: ThinkFeelDoEngine::Manage::TasksController

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

Overview

User manages task creation, destruction, and assignment for groups

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/manage/tasks_controller.rb', line 16

def create
  @task = current_user.tasks.build(task_params)
  authorize! :create, @task
  if @task.save
    redirect_to arm_manage_tasks_group_path(@group.arm, @group),
                notice: "Task assigned."
  else
    errors = @task.errors.full_messages.join(", ")
    flash[:alert] = "Unable to assign task: #{ errors }"
    redirect_to arm_manage_tasks_group_path(@group.arm, @group)
  end
end

#destroyObject



29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/think_feel_do_engine/manage/tasks_controller.rb', line 29

def destroy
  authorize! :destroy, @task
  group = @task.group
  if @task.destroy
    flash.now[:success] = "Task unassigned from group."
    redirect_to arm_manage_tasks_group_path(group.arm, group)
  else
    errors = @task.errors.full_messages.join(", ")
    flash[:error] = "Unable to delete task from group: #{ errors }"
    redirect_to arm_manage_tasks_group_path(group.arm, group)
  end
end

#indexObject



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

def index
  authorize! :update, @group
  @learning_tasks = @group.learning_tasks
end