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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 13 additions & 3 deletions app/controllers/teams_controller.rb
Original file line number Diff line number Diff line change
@@ -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
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
33 changes: 10 additions & 23 deletions app/views/teams/create.html.erb
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<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.
-->
</body>
</html>
<h1>Basketball Team</h1>
<div>
<p>Team Name: <%= @team.name %></p>
<p>Coach: <%= @team.coach %></p>
<p>Point Guard: <%= @team.pg%></p>
<p>Shooting Guard: <%= @team.sg %></p>
<p>Power Forward: <%= @team.pf%></p>
<p>Small Forward: <%= @team.sf %></p>
<p>Center: <%= @team.c %></p>
</div>
63 changes: 45 additions & 18 deletions app/views/teams/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,20 +1,47 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<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
-->
<h1>New Basketball Team</h1>

<%= form_with model: @team, url: '/team' do |form| %>
<div>
<%= form.label :name %>
<%= form.text_field :name, id: "name"%>
</div>

<div>
<%= form.label :coach %>
<%= form.text_field :coach, id: "coach"%>
</div>

<div>
<%= form.label :pg %>
<%= form.text_field :pg, id: "pg"%>
</div>

<div>
<%= form.label :sg %>
<%= form.text_field :sg, id: "sg" %>
</div>

<div>
<%= form.label :pf %>
<%= form.text_field :pf, id: "pf" %>
</div>

<div>
<%= form.label :sf%>
<%= form.text_field :sf, id: "sf" %>
</div>

<div>
<%= form.label :c %>
<%= form.text_field :c, id: "c" %>
</div>

<div>
<%= form.submit "Submit"%>
</div>
<% end %>
</body>
</html>


#url: use it for a path instead.
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file modified db/development.sqlite3
Binary file not shown.
15 changes: 15 additions & 0 deletions db/migrate/20250820012730_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_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
Binary file modified db/test.sqlite3
Binary file not shown.