diff --git a/Gemfile b/Gemfile index 4bfb083..1436c42 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,7 @@ gem 'omniauth' gem 'puma', '>= 5.0' gem 'rails', '~> 7.1.4' gem 'redis', '>= 4.0.1' +gem 'simple_form' gem 'sprockets-rails' gem 'sqlite3', '>= 1.4' gem 'stimulus-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 284c0b4..db1c8f7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -315,6 +315,9 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) + simple_form (5.3.1) + actionpack (>= 5.2) + activemodel (>= 5.2) sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -409,6 +412,7 @@ DEPENDENCIES redis (>= 4.0.1) rspec-rails selenium-webdriver + simple_form sprockets-rails sqlite3 (>= 1.4) stimulus-rails diff --git a/app/controllers/tools_controller.rb b/app/controllers/tools_controller.rb index ed29fb7..8d2e99c 100644 --- a/app/controllers/tools_controller.rb +++ b/app/controllers/tools_controller.rb @@ -4,4 +4,29 @@ class ToolsController < ApplicationController def index @tools = Tool.all end + + def new + return redirect_to new_user_session_path, status: :see_other unless current_user.present? + + @tool = Tool.new + end + + def create + return redirect_to tools_path unless current_user.present? + + @tool = Tool.new(tool_params) + @tool.user = current_user + + if @tool.save + redirect_to tools_path + else + render :new, status: :unprocessable_entity + end + end + + private + + def tool_params + params.require(:tool).permit(:name, :brand_name) + end end diff --git a/app/views/home/show.html.erb b/app/views/home/show.html.erb index 302144f..7ef8c69 100644 --- a/app/views/home/show.html.erb +++ b/app/views/home/show.html.erb @@ -1,11 +1,16 @@
- Welcome to the Hudson Valley Tool Library -
-- These are the current tools that we have available -
++ Welcome to the Hudson Valley Tool Library +
++ These are the current tools that we have available +
+Hudson Valley
-Tool Share
+Catskill Community Tools