From 8040e8789635bd114edc315e9431e6ba1d2e507c Mon Sep 17 00:00:00 2001 From: Emily Kanarek Date: Mon, 18 Aug 2025 15:58:24 -0400 Subject: [PATCH 1/4] Create Team model and new/create actions --- app/controllers/teams_controller.rb | 10 +++++++--- app/models/team.rb | 2 ++ config/routes.rb | 6 ++---- db/development.sqlite3 | Bin 0 -> 28672 bytes db/migrate/20250818195719_create_teams.rb | 15 +++++++++++++++ db/schema.rb | 15 ++++++++++++++- db/test.sqlite3 | Bin 20480 -> 28672 bytes 7 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 app/models/team.rb create mode 100644 db/migrate/20250818195719_create_teams.rb diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index d8cd2dc..231f005 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -1,5 +1,9 @@ class TeamsController < ApplicationController - # TODO: Add your controller actions here - # You'll need a 'new' action to display the form - # You'll need a 'create' action to process the form submission + def new + @team = Team.new + end + + def create + @team = Team.create(params.require(:team).permit(:name, :coach, :pg, :sg, :pf, :sf, :c)) + end end diff --git a/app/models/team.rb b/app/models/team.rb new file mode 100644 index 0000000..48a6c83 --- /dev/null +++ b/app/models/team.rb @@ -0,0 +1,2 @@ +class Team < ApplicationRecord +end diff --git a/config/routes.rb b/config/routes.rb index 0536571..13291c2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,4 @@ Rails.application.routes.draw do - # TODO: Add your routes here - # You need: - # - A GET route to '/newteam' that goes to the teams controller new action - # - A POST route to '/team' that goes to the teams controller create action + get '/newteam', to: 'teams#new' + resources :teams, only: :create end diff --git a/db/development.sqlite3 b/db/development.sqlite3 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..30f6237aad978e353de5cee73e68159c7cf3e125 100644 GIT binary patch literal 28672 zcmeI)J#X4T7zglkcq>(j)5$}Jp3DNut3#bYy40;u6@@^Wk|F9~UCafnVgt58>6rAJ z^b2I_*soM6ojUdmNrZ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2*Uu=L>*&MRtCMIMZEk!7+CnE8ThUFxAIBzecCK2u$-5< zF@$;Y0Ui@ZmdRgv7O=9giAS4Gj^&e>yopzfnYDs(@_k-CMyAPpd|p5@lFvby8E7yE z$Z%dDX5|0P!2cU)(0hJC1_owECVm4hRAF`o1{P+1PJ>MWQT#FHNv7s$hQ>)Ii58ZI zh6ZNINk(R7X_n^3M#+|mi7ClRsfnp6CMjk{21cg31{S)8Mhb@JRtBb4h6Z|Oh6W~< chPY)WZ;O}LLRN2JX>5$$B#_MJ|M83h0EtFJT>t<8 From ff9894e05595e0aeeda18915801241c0016c21f8 Mon Sep 17 00:00:00 2001 From: Emily Kanarek Date: Mon, 18 Aug 2025 16:12:51 -0400 Subject: [PATCH 2/4] Create team form --- app/views/teams/new.html.erb | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/app/views/teams/new.html.erb b/app/views/teams/new.html.erb index 4be4bef..5f520b8 100644 --- a/app/views/teams/new.html.erb +++ b/app/views/teams/new.html.erb @@ -5,16 +5,22 @@ Basketball Team Signup - + <%= form_with model: @team, local: true do |f| %> + <%= label_tag :name, "Team name:" %> + <%= text_field_tag :name %> + <%= label_tag :coach, "Coach:" %> + <%= text_field_tag :coach %> + <%= label_tag :pg, "Point Guard:" %> + <%= text_field_tag :pg %> + <%= label_tag :sg, "Shooting Guard:" %> + <%= text_field_tag :sg %> + <%= label_tag :pf, "Power Forward:" %> + <%= text_field_tag :pf %> + <%= label_tag :sf, "Small Forward:" %> + <%= text_field_tag :sf %> + <%= label_tag :c, "Center:" %> + <%= text_field_tag :c %> + <%= submit_tag "Submit" %> + <% end %> From 16fef53d5320e96cd3a2ad704e52d877fac72566 Mon Sep 17 00:00:00 2001 From: Emily Kanarek Date: Mon, 18 Aug 2025 16:16:31 -0400 Subject: [PATCH 3/4] Display new team's info --- app/controllers/teams_controller.rb | 2 +- app/views/teams/create.html.erb | 33 ++++++++++++++++++----------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index 231f005..9ac63ea 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -4,6 +4,6 @@ def new end def create - @team = Team.create(params.require(:team).permit(:name, :coach, :pg, :sg, :pf, :sf, :c)) + @team = Team.create(params.permit(:name, :coach, :pg, :sg, :pf, :sf, :c)) end end diff --git a/app/views/teams/create.html.erb b/app/views/teams/create.html.erb index 3d56f29..0b99edf 100644 --- a/app/views/teams/create.html.erb +++ b/app/views/teams/create.html.erb @@ -5,19 +5,28 @@ Basketball Team - + # Use the data passed from your controller action. + # --> +
    +
  • Team Name: <%= @team.name %>
  • +
  • Coach: <%= @team.coach %>
  • +
  • Point Guard: <%= @team.pg %>
  • +
  • Shooting Guard: <%= @team.sg %>
  • +
  • Power Forward: <%= @team.pf %>
  • +
  • Small Forward: <%= @team.sf %>
  • +
  • Center: <%= @team.c %>
  • +
From 5740ace17671ae33653b4c1e6842065d96f639fc Mon Sep 17 00:00:00 2001 From: Emily Kanarek Date: Mon, 18 Aug 2025 16:17:12 -0400 Subject: [PATCH 4/4] Remove comments --- app/views/teams/create.html.erb | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/app/views/teams/create.html.erb b/app/views/teams/create.html.erb index 0b99edf..ddb4e3d 100644 --- a/app/views/teams/create.html.erb +++ b/app/views/teams/create.html.erb @@ -5,20 +5,6 @@ Basketball Team - #
  • Team Name: <%= @team.name %>
  • Coach: <%= @team.coach %>