diff --git a/Gemfile b/Gemfile index 1a1b15d..8de6415 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gem 'fiddle' gem 'logger' gem 'mutex_m' gem 'ostruct' - +gem 'pry' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' gem 'rails', '~> 6.1.3', '>= 6.1.3.1' # Use sqlite3 as the database for Active Record (updated for Ruby 3.3 compatibility) diff --git a/Gemfile.lock b/Gemfile.lock index caea9fb..b96a561 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -76,6 +76,7 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) + coderay (1.1.3) concurrent-ruby (1.3.5) crass (1.0.6) date (3.4.1) @@ -131,6 +132,9 @@ GEM ast (~> 2.4.1) racc prism (1.4.0) + pry (0.15.2) + coderay (~> 1.1) + method_source (~> 1.0) public_suffix (6.0.2) puma (5.6.9) nio4r (~> 2.0) @@ -253,6 +257,7 @@ DEPENDENCIES mutex_m nio4r (~> 2.7) ostruct + pry puma (~> 5.0) rack-cors rails (~> 6.1.3, >= 6.1.3.1) diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index d8cd2dc..89fccec 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -1,5 +1,15 @@ 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(team_params) + end + + private + + def team_params + 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/app/views/teams/create.html.erb b/app/views/teams/create.html.erb index 3d56f29..2e5eda0 100644 --- a/app/views/teams/create.html.erb +++ b/app/views/teams/create.html.erb @@ -1,23 +1,10 @@ - - - - - Basketball Team - - - - - +

Basketball Team

+
+

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 %>

+
diff --git a/app/views/teams/new.html.erb b/app/views/teams/new.html.erb index 4be4bef..d53f2e3 100644 --- a/app/views/teams/new.html.erb +++ b/app/views/teams/new.html.erb @@ -1,20 +1,47 @@ - - - - - Basketball Team Signup - - - +

New Basketball Team

+ + <%= form_with model: @team, url: '/team' do |form| %> +
+ <%= form.label :name %> + <%= form.text_field :name, id: "name"%> +
+ +
+ <%= form.label :coach %> + <%= form.text_field :coach, id: "coach"%> +
+ +
+ <%= form.label :pg %> + <%= form.text_field :pg, id: "pg"%> +
+ +
+ <%= form.label :sg %> + <%= form.text_field :sg, id: "sg" %> +
+ +
+ <%= form.label :pf %> + <%= form.text_field :pf, id: "pf" %> +
+ +
+ <%= form.label :sf%> + <%= form.text_field :sf, id: "sf" %> +
+ +
+ <%= form.label :c %> + <%= form.text_field :c, id: "c" %> +
+ +
+ <%= form.submit "Submit"%> +
+ <% end %> + + +#url: use it for a path instead. diff --git a/config/routes.rb b/config/routes.rb index 0536571..83b5c6d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,4 +3,6 @@ # 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' + post '/team', to: 'teams#create' end diff --git a/db/development.sqlite3 b/db/development.sqlite3 index e69de29..2120f39 100644 Binary files a/db/development.sqlite3 and b/db/development.sqlite3 differ diff --git a/db/migrate/20250820012730_create_teams.rb b/db/migrate/20250820012730_create_teams.rb new file mode 100644 index 0000000..fb05523 --- /dev/null +++ b/db/migrate/20250820012730_create_teams.rb @@ -0,0 +1,15 @@ +class CreateTeams < ActiveRecord::Migration[6.1] + def change + create_table :teams do |t| + t.string :name + t.string :coach + t.string :pg + t.string :sg + t.string :pf + t.string :sf + t.string :c + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index ae89000..c90891c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,5 +10,18 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 0) do +ActiveRecord::Schema.define(version: 2025_08_20_012730) do + + create_table "teams", force: :cascade do |t| + t.string "name" + t.string "coach" + t.string "pg" + t.string "sg" + t.string "pf" + t.string "sf" + t.string "c" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + end diff --git a/db/test.sqlite3 b/db/test.sqlite3 index d5994e4..59c9f4b 100644 Binary files a/db/test.sqlite3 and b/db/test.sqlite3 differ