remove edit.html.erb

This commit is contained in:
Ben Harris 2022-01-15 12:32:36 -05:00
parent 2c8c227493
commit 1d9a622303
Signed by: ben
GPG Key ID: 4E0AF802FFF7960C
13 changed files with 24 additions and 77 deletions

View File

@ -5,7 +5,7 @@ class MachinesController < ApplicationController
# GET /machines or /machines.json # GET /machines or /machines.json
def index def index
@machines = Machine.all @machines = Machine.order(:name)
end end
# GET /machines/1 or /machines/1.json # GET /machines/1 or /machines/1.json
@ -25,7 +25,7 @@ class MachinesController < ApplicationController
respond_to do |format| respond_to do |format|
if @machine.save if @machine.save
format.html { redirect_to machine_url(@machine), notice: 'Machine was successfully created.' } format.html { redirect_to machines_url, notice: 'Machine was successfully created.' }
format.json { render :show, status: :created, location: @machine } format.json { render :show, status: :created, location: @machine }
else else
format.html { render :new, status: :unprocessable_entity } format.html { render :new, status: :unprocessable_entity }
@ -38,10 +38,10 @@ class MachinesController < ApplicationController
def update def update
respond_to do |format| respond_to do |format|
if @machine.update(machine_params) if @machine.update(machine_params)
format.html { redirect_to machine_url(@machine), notice: 'Machine was successfully updated.' } format.html { redirect_to machines_url, notice: 'Machine was successfully updated.' }
format.json { render :show, status: :ok, location: @machine } format.json { render :show, status: :ok, location: @machine }
else else
format.html { render :edit, status: :unprocessable_entity } format.html { render :show, status: :unprocessable_entity }
format.json { render json: @machine.errors, status: :unprocessable_entity } format.json { render json: @machine.errors, status: :unprocessable_entity }
end end
end end

View File

@ -5,7 +5,7 @@ class PlayersController < ApplicationController
# GET /players or /players.json # GET /players or /players.json
def index def index
@players = Player.all @players = Player.order(:name)
end end
# GET /players/1 or /players/1.json # GET /players/1 or /players/1.json
@ -16,16 +16,13 @@ class PlayersController < ApplicationController
@player = Player.new @player = Player.new
end end
# GET /players/1/edit
def edit; end
# POST /players or /players.json # POST /players or /players.json
def create def create
@player = Player.new(player_params) @player = Player.new(player_params)
respond_to do |format| respond_to do |format|
if @player.save if @player.save
format.html { redirect_to player_url(@player), notice: 'Player was successfully created.' } format.html { redirect_to players_url, notice: 'Player was successfully created.' }
format.json { render :show, status: :created, location: @player } format.json { render :show, status: :created, location: @player }
else else
format.html { render :new, status: :unprocessable_entity } format.html { render :new, status: :unprocessable_entity }
@ -38,10 +35,10 @@ class PlayersController < ApplicationController
def update def update
respond_to do |format| respond_to do |format|
if @player.update(player_params) if @player.update(player_params)
format.html { redirect_to player_url(@player), notice: 'Player was successfully updated.' } format.html { redirect_to players_url, notice: 'Player was successfully updated.' }
format.json { render :show, status: :ok, location: @player } format.json { render :show, status: :ok, location: @player }
else else
format.html { render :edit, status: :unprocessable_entity } format.html { render :show, status: :unprocessable_entity }
format.json { render json: @player.errors, status: :unprocessable_entity } format.json { render json: @player.errors, status: :unprocessable_entity }
end end
end end

View File

@ -11,6 +11,11 @@
</head> </head>
<body> <body>
<nav>
<%= link_to "Pins", machines_url %>
<%= link_to "Players", players_url %>
</nav>
<%= yield %> <%= yield %>
</body> </body>
</html> </html>

View File

@ -1,12 +1,6 @@
<div id="<%= dom_id machine %>"> <div id="<%= dom_id machine %>">
<p> <p>
<strong>Name:</strong> <%= link_to machine.name, machine %>
<%= machine.name %> <small><%= machine.edition %></small>
</p> </p>
<p>
<strong>Edition:</strong>
<%= machine.edition %>
</p>
</div> </div>

View File

@ -1,10 +0,0 @@
<h1>Editing machine</h1>
<%= render "form", machine: @machine %>
<br>
<div>
<%= link_to "Show this machine", @machine %> |
<%= link_to "Back to machines", machines_path %>
</div>

View File

@ -1,13 +1,10 @@
<p style="color: green"><%= notice %></p> <p style="color: green"><%= notice %></p>
<h1>Machines</h1> <h1>Pins</h1>
<div id="machines"> <div id="machines">
<% @machines.each do |machine| %> <% @machines.each do |machine| %>
<%= render machine %> <%= render machine %>
<p>
<%= link_to "Show this machine", machine %>
</p>
<% end %> <% end %>
</div> </div>

View File

@ -1,9 +1,8 @@
<p style="color: green"><%= notice %></p> <p style="color: green"><%= notice %></p>
<%= render @machine %> <%= render "form", machine: @machine %>
<div> <div>
<%= link_to "Edit this machine", edit_machine_path(@machine) %> |
<%= link_to "Back to machines", machines_path %> <%= link_to "Back to machines", machines_path %>
<%= button_to "Destroy this machine", @machine, method: :delete %> <%= button_to "Destroy this machine", @machine, method: :delete %>

View File

@ -1,17 +1,6 @@
<div id="<%= dom_id player %>"> <div id="<%= dom_id player %>">
<p> <p>
<strong>Name:</strong> <% if player.paid %>✓<% else %>&nbsp;<% end %>
<%= player.name %> <%= link_to player.name, player %>
</p> </p>
<p>
<strong>Paid:</strong>
<%= player.paid %>
</p>
<p>
<strong>Strikes:</strong>
<%= player.strikes %>
</p>
</div> </div>

View File

@ -1,10 +0,0 @@
<h1>Editing player</h1>
<%= render "form", player: @player %>
<br>
<div>
<%= link_to "Show this player", @player %> |
<%= link_to "Back to players", players_path %>
</div>

View File

@ -5,9 +5,6 @@
<div id="players"> <div id="players">
<% @players.each do |player| %> <% @players.each do |player| %>
<%= render player %> <%= render player %>
<p>
<%= link_to "Show this player", player %>
</p>
<% end %> <% end %>
</div> </div>

View File

@ -1,9 +1,8 @@
<p style="color: green"><%= notice %></p> <p style="color: green"><%= notice %></p>
<%= render @player %> <%= render "form", player: @player %>
<div> <div>
<%= link_to "Edit this player", edit_player_path(@player) %> |
<%= link_to "Back to players", players_path %> <%= link_to "Back to players", players_path %>
<%= button_to "Destroy this player", @player, method: :delete %> <%= button_to "Destroy this player", @player, method: :delete %>

View File

@ -22,7 +22,7 @@ class MachinesControllerTest < ActionDispatch::IntegrationTest
post machines_url, params: { machine: { edition: @machine.edition, name: @machine.name } } post machines_url, params: { machine: { edition: @machine.edition, name: @machine.name } }
end end
assert_redirected_to machine_url(Machine.last) assert_redirected_to machines_url
end end
test 'should show machine' do test 'should show machine' do
@ -30,14 +30,9 @@ class MachinesControllerTest < ActionDispatch::IntegrationTest
assert_response :success assert_response :success
end end
test 'should get edit' do
get edit_machine_url(@machine)
assert_response :success
end
test 'should update machine' do test 'should update machine' do
patch machine_url(@machine), params: { machine: { edition: @machine.edition, name: @machine.name } } patch machine_url(@machine), params: { machine: { edition: @machine.edition, name: @machine.name } }
assert_redirected_to machine_url(@machine) assert_redirected_to machines_url
end end
test 'should destroy machine' do test 'should destroy machine' do

View File

@ -22,7 +22,7 @@ class PlayersControllerTest < ActionDispatch::IntegrationTest
post players_url, params: { player: { name: @player.name, paid: @player.paid, strikes: @player.strikes } } post players_url, params: { player: { name: @player.name, paid: @player.paid, strikes: @player.strikes } }
end end
assert_redirected_to player_url(Player.last) assert_redirected_to players_url
end end
test 'should show player' do test 'should show player' do
@ -30,14 +30,9 @@ class PlayersControllerTest < ActionDispatch::IntegrationTest
assert_response :success assert_response :success
end end
test 'should get edit' do
get edit_player_url(@player)
assert_response :success
end
test 'should update player' do test 'should update player' do
patch player_url(@player), params: { player: { name: @player.name, paid: @player.paid, strikes: @player.strikes } } patch player_url(@player), params: { player: { name: @player.name, paid: @player.paid, strikes: @player.strikes } }
assert_redirected_to player_url(@player) assert_redirected_to players_url
end end
test 'should destroy player' do test 'should destroy player' do