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
14 changes: 11 additions & 3 deletions app/controllers/teams_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
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; end

def create
@team = team_params
end

private

def team_params
params.permit(:name, :coach, :pg, :sg, :pf, :sf, :c)
end
end
35 changes: 17 additions & 18 deletions app/views/teams/create.html.erb
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
<!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]
<head>
<meta charset="UTF-8">
<title>Basketball Team</title>
</head>

<body>
<h1>Created Team</h1>
<ul>
<li>Team Name: <%= @team[:name] %> </li>
<li>Coach: <%= @team[:coach] %> </li>
<li>Point Guard: <%= @team[:pg] %> </li>
<li>Power Forward: <%= @team[:pf] %> </li>
<li>Small Forward: <%= @team[:sf] %> </li>
<li>Shooting Guard: <%= @team[:sg] %> </li>
<li>Center: <%= @team[:c] %> </li>
</ul>
</body>

Use the data passed from your controller action.
-->
</body>
</html>
54 changes: 39 additions & 15 deletions app/views/teams/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,20 +1,44 @@
<!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"
<head>
<meta charset="UTF-8">
<title>Basketball Team Signup</title>
</head>

<body>
<h1>Team Creation Form</h1>
<%= form_with model: @team, local: true, url: '/team', method: :post do |form| %>
<div>
<%= form.label :name %>
<%= form.text_field :name %>
</div>
<div>
<%= form.label :coach %>
<%= form.text_field :coach %>
</div>
<div>
<%= form.label :pg, "Point Guard" %>
<%= form.text_field :pg %>
</div>
<div>
<%= form.label :sg, "Shooting Guard" %>
<%= form.text_field :sg %>
</div>
<div>
<%= form.label :pf, "Power Forward" %>
<%= form.text_field :pf %>
</div>
<div>
<%= form.label :sf, "Small Forward" %>
<%= form.text_field :sf %>
</div>
<div>
<%= form.label :c, "Center" %>
<%= form.text_field :c %>
</div>
<%= form.submit id: "Submit" %>
<% end %>
</body>

Hint: Use form_with helper
-->
</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'
post '/team', to: 'teams#create'
end
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.