summaryrefslogtreecommitdiff
path: root/app/controllers/tasks_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/tasks_controller.rb')
-rw-r--r--app/controllers/tasks_controller.rb17
1 files changed, 13 insertions, 4 deletions
diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb
index a8f1b07..f072770 100644
--- a/app/controllers/tasks_controller.rb
+++ b/app/controllers/tasks_controller.rb
@@ -1,13 +1,22 @@
class TasksController < ApplicationController
- before_action :set_tasks, only: [:show]
+ before_action :set_task_list
def show
- @task = @tasks.find(params[:id])
+ @task = @task_list.tasks.find(params[:id])
+ end
+
+ def create
+ @task_list.tasks.create!(task_params)
+ redirect_to @task_list
end
private
- def set_tasks
- @tasks = TaskList.find(params[:task_list_id]).tasks
+ def task_params
+ params.require(:task).permit(:name)
+ end
+
+ def set_task_list
+ @task_list = TaskList.find(params[:task_list_id])
end
end