diff options
author | Nick Van Doorn <nick@super.gd> | 2020-10-26 00:39:04 -0700 |
---|---|---|
committer | Nick Van Doorn <nick@super.gd> | 2020-10-26 00:39:04 -0700 |
commit | bbfe70372e27fea204180375c7b44e60ef7e31a9 (patch) | |
tree | 7c541d21629f7c7b88a2228fa83e96792e70346f | |
parent | e14ec24dcfd18b039dbca53b7eb8c391b0f6cf01 (diff) |
Revive project
Sorry
-rw-r--r-- | .ruby-version | 2 | ||||
-rw-r--r-- | Gemfile | 4 | ||||
-rw-r--r-- | Gemfile.lock | 4 | ||||
-rw-r--r-- | app/controllers/task_lists_controller.rb | 1 | ||||
-rw-r--r-- | app/controllers/tasks_controller.rb | 17 | ||||
-rw-r--r-- | app/views/task_lists/index.html.erb | 2 | ||||
-rw-r--r-- | app/views/task_lists/show.html.erb | 8 | ||||
-rw-r--r-- | app/views/tasks/new.html.erb | 5 | ||||
-rw-r--r-- | vendor/.keep | 0 |
9 files changed, 31 insertions, 12 deletions
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 @@ -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 %> - <ul> <% @task_lists.each do |task_list| %> <li><%= link_to task_list.name, task_list_path(task_list) %></li> diff --git a/app/views/task_lists/show.html.erb b/app/views/task_lists/show.html.erb index 6ddffe2..3d0a784 100644 --- a/app/views/task_lists/show.html.erb +++ b/app/views/task_lists/show.html.erb @@ -1,4 +1,10 @@ -<%= @task_list.name %> +<h1><%= @task_list.name %></h1> + +<%= form_for @task, url: [@task_list, @task] do |f| %> + <%= f.label :name %> + <%= f.text_field :name %> + <%= f.submit "Create task" %> +<% end %> <ul> <% @task_list.tasks.each do |task| %> diff --git a/app/views/tasks/new.html.erb b/app/views/tasks/new.html.erb new file mode 100644 index 0000000..e798e0c --- /dev/null +++ b/app/views/tasks/new.html.erb @@ -0,0 +1,5 @@ +<%= form_for @task, url: [@task_list, @task] do |f| %> + <%= f.label :name %> + <%= f.text_field :name %> + <%= f.submit "Create task" %> +<% end %> diff --git a/vendor/.keep b/vendor/.keep deleted file mode 100644 index e69de29..0000000 --- a/vendor/.keep +++ /dev/null |