From bbfe70372e27fea204180375c7b44e60ef7e31a9 Mon Sep 17 00:00:00 2001 From: Nick Van Doorn Date: Mon, 26 Oct 2020 00:39:04 -0700 Subject: Revive project Sorry --- .ruby-version | 2 +- Gemfile | 4 ++-- Gemfile.lock | 4 ++-- app/controllers/task_lists_controller.rb | 1 + app/controllers/tasks_controller.rb | 17 +++++++++++++---- app/views/task_lists/index.html.erb | 2 -- app/views/task_lists/show.html.erb | 8 +++++++- app/views/tasks/new.html.erb | 5 +++++ vendor/.keep | 0 9 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 app/views/tasks/new.html.erb delete mode 100644 vendor/.keep diff --git a/.ruby-version b/.ruby-version index 57cf282..338a5b5 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.5 +2.6.6 diff --git a/Gemfile b/Gemfile index ab0e615..7dc168e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,10 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby '2.6.5' +ruby '2.6.6' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 6.0.2', '>= 6.0.2.1' +gem 'rails', '~> 6.0.2' # Use postgresql as the database for Active Record gem 'pg', '>= 0.18', '< 2.0' # Use Puma as the app server diff --git a/Gemfile.lock b/Gemfile.lock index 8798355..4fd8104 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -188,7 +188,7 @@ DEPENDENCIES pg (>= 0.18, < 2.0) pry (~> 0.12.2) puma (~> 4.1) - rails (~> 6.0.2, >= 6.0.2.1) + rails (~> 6.0.2) sass-rails (>= 6) spring spring-watcher-listen (~> 2.0.0) @@ -198,7 +198,7 @@ DEPENDENCIES webpacker (~> 4.0) RUBY VERSION - ruby 2.6.5p114 + ruby 2.6.6p146 BUNDLED WITH 2.1.4 diff --git a/app/controllers/task_lists_controller.rb b/app/controllers/task_lists_controller.rb index 98b12f4..cbd2307 100644 --- a/app/controllers/task_lists_controller.rb +++ b/app/controllers/task_lists_controller.rb @@ -6,6 +6,7 @@ class TaskListsController < ApplicationController end def show + @task = Task.new end def new 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 diff --git a/app/views/task_lists/index.html.erb b/app/views/task_lists/index.html.erb index f405498..f8905b8 100644 --- a/app/views/task_lists/index.html.erb +++ b/app/views/task_lists/index.html.erb @@ -1,5 +1,3 @@ -<%= link_to "Create a new list", new_task_list_path %> -