Class: Todoro::TasksController

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

Instance Method Summary collapse

Instance Method Details

#completeObject



34
35
36
37
# File 'app/controllers/todoro/tasks_controller.rb', line 34

def complete
  @task.update(status: "completed")
  redirect_to task_list_path(taskable: @task_list.taskable.class.name, taskable_id: @task_list.taskable.id, id: @task_list.id), notice: "Task marked as completed."
end

#createObject



10
11
12
13
14
15
16
17
# File 'app/controllers/todoro/tasks_controller.rb', line 10

def create
  @task = @task_list.tasks.new(task_params)
  if @task.save
    redirect_to task_list_path(taskable: @task_list.taskable.class.name, taskable_id: @task_list.taskable.id, id: @task_list.id), notice: "Task created successfully."
  else
    render :new
  end
end

#destroyObject



29
30
31
32
# File 'app/controllers/todoro/tasks_controller.rb', line 29

def destroy
  @task.destroy
  redirect_to @task_list, notice: "Task deleted."
end

#editObject



19
# File 'app/controllers/todoro/tasks_controller.rb', line 19

def edit; end

#newObject



6
7
8
# File 'app/controllers/todoro/tasks_controller.rb', line 6

def new
  @task = @task_list.tasks.new
end

#updateObject



21
22
23
24
25
26
27
# File 'app/controllers/todoro/tasks_controller.rb', line 21

def update
  if @task.update(task_params)
    redirect_to @task_list, notice: "Task updated successfully."
  else
    render :edit
  end
end