Sha256: 25f305b978610d3b42d4ac25f815926adf31b6dfaf01198ea9b9029df92adf99
Contents?: true
Size: 1.91 KB
Versions: 41
Compression:
Stored size: 1.91 KB
Contents
require_dependency "think_feel_do_engine/application_controller" module ThinkFeelDoEngine module Manage # User manages task creation, destruction, and assignment for groups class TasksController < ApplicationController before_action :authenticate_user! before_action :set_group, only: [:index, :create] before_action :set_task, only: :destroy def index authorize! :update, @group @learning_tasks = @group.learning_tasks end 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 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 private def build_task current_user .tasks .build(task_params) end def set_group @group = Group.find(task_params[:group_id]) end def set_task @task = Task.find(params[:id]) end def task_params params.require(:task).permit( :bit_core_content_module_id, :group_id, :is_recurring, :release_day, :termination_day, :has_didactic_content ) end end end end
Version data entries
41 entries across 41 versions & 1 rubygems