Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions app/controllers/teams_controller.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions app/models/team.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Team < ApplicationRecord
end
23 changes: 9 additions & 14 deletions app/views/teams/create.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,14 @@
<title>Basketball Team</title>
</head>
<body>
<!--
TODO: Display the team information here!

Your view should display:
- Team Name: [team name]
- Coach: [coach name]
- Point Guard: [pg name]
- Shooting Guard: [sg name]
- Power Forward: [pf name]
- Small Forward: [sf name]
- Center: [c name]

Use the data passed from your controller action.
-->
<ul>
<li>Team Name: <%= @team.name %></li>
<li>Coach: <%= @team.coach %></li>
<li>Point Guard: <%= @team.pg %></li>
<li>Shooting Guard: <%= @team.sg %></li>
<li>Power Forward: <%= @team.pf %></li>
<li>Small Forward: <%= @team.sf %></li>
<li>Center: <%= @team.c %></li>
</ul>
</body>
</html>
28 changes: 17 additions & 11 deletions app/views/teams/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@
<title>Basketball Team Signup</title>
</head>
<body>
<!--
TODO: Create your form here!

Your form should:
- Use Rails form helpers
- Submit to '/team' with POST method
- Have fields for: name, coach, pg, sg, pf, sf, c
- Have a submit button with id="Submit"

Hint: Use form_with helper
-->
<%= 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 %>
</body>
</html>
6 changes: 2 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -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
Binary file modified db/development.sqlite3
Binary file not shown.
15 changes: 15 additions & 0 deletions db/migrate/20250818195719_create_teams.rb
Original file line number Diff line number Diff line change
@@ -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
15 changes: 14 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file modified db/test.sqlite3
Binary file not shown.