diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index d8cd2dc..9ac63ea 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.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..ddb4e3d 100644 --- a/app/views/teams/create.html.erb +++ b/app/views/teams/create.html.erb @@ -5,19 +5,14 @@ Basketball Team - + 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 %> 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 e69de29..30f6237 100644 Binary files a/db/development.sqlite3 and b/db/development.sqlite3 differ diff --git a/db/migrate/20250818195719_create_teams.rb b/db/migrate/20250818195719_create_teams.rb new file mode 100644 index 0000000..fb05523 --- /dev/null +++ b/db/migrate/20250818195719_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..e6bf1c0 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_18_195719) 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..eba438c 100644 Binary files a/db/test.sqlite3 and b/db/test.sqlite3 differ