From 1d9a622303d7ef6c2f1db99d759554c268767cc4 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sat, 15 Jan 2022 12:32:36 -0500 Subject: [PATCH] remove edit.html.erb --- app/controllers/machines_controller.rb | 8 ++++---- app/controllers/players_controller.rb | 11 ++++------- app/views/layouts/application.html.erb | 5 +++++ app/views/machines/_machine.html.erb | 10 ++-------- app/views/machines/edit.html.erb | 10 ---------- app/views/machines/index.html.erb | 5 +---- app/views/machines/show.html.erb | 3 +-- app/views/players/_player.html.erb | 15 ++------------- app/views/players/edit.html.erb | 10 ---------- app/views/players/index.html.erb | 3 --- app/views/players/show.html.erb | 3 +-- test/controllers/machines_controller_test.rb | 9 ++------- test/controllers/players_controller_test.rb | 9 ++------- 13 files changed, 24 insertions(+), 77 deletions(-) delete mode 100644 app/views/machines/edit.html.erb delete mode 100644 app/views/players/edit.html.erb diff --git a/app/controllers/machines_controller.rb b/app/controllers/machines_controller.rb index d83a52f..3ef5893 100644 --- a/app/controllers/machines_controller.rb +++ b/app/controllers/machines_controller.rb @@ -5,7 +5,7 @@ class MachinesController < ApplicationController # GET /machines or /machines.json def index - @machines = Machine.all + @machines = Machine.order(:name) end # GET /machines/1 or /machines/1.json @@ -25,7 +25,7 @@ class MachinesController < ApplicationController respond_to do |format| 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 } else format.html { render :new, status: :unprocessable_entity } @@ -38,10 +38,10 @@ class MachinesController < ApplicationController def update respond_to do |format| 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 } else - format.html { render :edit, status: :unprocessable_entity } + format.html { render :show, status: :unprocessable_entity } format.json { render json: @machine.errors, status: :unprocessable_entity } end end diff --git a/app/controllers/players_controller.rb b/app/controllers/players_controller.rb index c1139e1..44034e5 100644 --- a/app/controllers/players_controller.rb +++ b/app/controllers/players_controller.rb @@ -5,7 +5,7 @@ class PlayersController < ApplicationController # GET /players or /players.json def index - @players = Player.all + @players = Player.order(:name) end # GET /players/1 or /players/1.json @@ -16,16 +16,13 @@ class PlayersController < ApplicationController @player = Player.new end - # GET /players/1/edit - def edit; end - # POST /players or /players.json def create @player = Player.new(player_params) respond_to do |format| 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 } else format.html { render :new, status: :unprocessable_entity } @@ -38,10 +35,10 @@ class PlayersController < ApplicationController def update respond_to do |format| 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 } else - format.html { render :edit, status: :unprocessable_entity } + format.html { render :show, status: :unprocessable_entity } format.json { render json: @player.errors, status: :unprocessable_entity } end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 665f897..a21e612 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -11,6 +11,11 @@ + + <%= yield %> diff --git a/app/views/machines/_machine.html.erb b/app/views/machines/_machine.html.erb index edba53e..c506363 100644 --- a/app/views/machines/_machine.html.erb +++ b/app/views/machines/_machine.html.erb @@ -1,12 +1,6 @@

- Name: - <%= machine.name %> + <%= link_to machine.name, machine %> + <%= machine.edition %>

- -

- Edition: - <%= machine.edition %> -

-
diff --git a/app/views/machines/edit.html.erb b/app/views/machines/edit.html.erb deleted file mode 100644 index a390477..0000000 --- a/app/views/machines/edit.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -

Editing machine

- -<%= render "form", machine: @machine %> - -
- -
- <%= link_to "Show this machine", @machine %> | - <%= link_to "Back to machines", machines_path %> -
diff --git a/app/views/machines/index.html.erb b/app/views/machines/index.html.erb index b5e2c85..2c99524 100644 --- a/app/views/machines/index.html.erb +++ b/app/views/machines/index.html.erb @@ -1,13 +1,10 @@

<%= notice %>

-

Machines

+

Pins

<% @machines.each do |machine| %> <%= render machine %> -

- <%= link_to "Show this machine", machine %> -

<% end %>
diff --git a/app/views/machines/show.html.erb b/app/views/machines/show.html.erb index 1af79f9..7870783 100644 --- a/app/views/machines/show.html.erb +++ b/app/views/machines/show.html.erb @@ -1,9 +1,8 @@

<%= notice %>

-<%= render @machine %> +<%= render "form", machine: @machine %>
- <%= link_to "Edit this machine", edit_machine_path(@machine) %> | <%= link_to "Back to machines", machines_path %> <%= button_to "Destroy this machine", @machine, method: :delete %> diff --git a/app/views/players/_player.html.erb b/app/views/players/_player.html.erb index 35e7cb1..4d1abeb 100644 --- a/app/views/players/_player.html.erb +++ b/app/views/players/_player.html.erb @@ -1,17 +1,6 @@

- Name: - <%= player.name %> + <% if player.paid %>✓<% else %> <% end %> + <%= link_to player.name, player %>

- -

- Paid: - <%= player.paid %> -

- -

- Strikes: - <%= player.strikes %> -

-
diff --git a/app/views/players/edit.html.erb b/app/views/players/edit.html.erb deleted file mode 100644 index a6cea2b..0000000 --- a/app/views/players/edit.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -

Editing player

- -<%= render "form", player: @player %> - -
- -
- <%= link_to "Show this player", @player %> | - <%= link_to "Back to players", players_path %> -
diff --git a/app/views/players/index.html.erb b/app/views/players/index.html.erb index eac7710..5a2b9ef 100644 --- a/app/views/players/index.html.erb +++ b/app/views/players/index.html.erb @@ -5,9 +5,6 @@
<% @players.each do |player| %> <%= render player %> -

- <%= link_to "Show this player", player %> -

<% end %>
diff --git a/app/views/players/show.html.erb b/app/views/players/show.html.erb index 19ade1d..42dce9c 100644 --- a/app/views/players/show.html.erb +++ b/app/views/players/show.html.erb @@ -1,9 +1,8 @@

<%= notice %>

-<%= render @player %> +<%= render "form", player: @player %>
- <%= link_to "Edit this player", edit_player_path(@player) %> | <%= link_to "Back to players", players_path %> <%= button_to "Destroy this player", @player, method: :delete %> diff --git a/test/controllers/machines_controller_test.rb b/test/controllers/machines_controller_test.rb index 61ec204..03b68e4 100644 --- a/test/controllers/machines_controller_test.rb +++ b/test/controllers/machines_controller_test.rb @@ -22,7 +22,7 @@ class MachinesControllerTest < ActionDispatch::IntegrationTest post machines_url, params: { machine: { edition: @machine.edition, name: @machine.name } } end - assert_redirected_to machine_url(Machine.last) + assert_redirected_to machines_url end test 'should show machine' do @@ -30,14 +30,9 @@ class MachinesControllerTest < ActionDispatch::IntegrationTest assert_response :success end - test 'should get edit' do - get edit_machine_url(@machine) - assert_response :success - end - test 'should update machine' do patch machine_url(@machine), params: { machine: { edition: @machine.edition, name: @machine.name } } - assert_redirected_to machine_url(@machine) + assert_redirected_to machines_url end test 'should destroy machine' do diff --git a/test/controllers/players_controller_test.rb b/test/controllers/players_controller_test.rb index 8e446f0..cd78d68 100644 --- a/test/controllers/players_controller_test.rb +++ b/test/controllers/players_controller_test.rb @@ -22,7 +22,7 @@ class PlayersControllerTest < ActionDispatch::IntegrationTest post players_url, params: { player: { name: @player.name, paid: @player.paid, strikes: @player.strikes } } end - assert_redirected_to player_url(Player.last) + assert_redirected_to players_url end test 'should show player' do @@ -30,14 +30,9 @@ class PlayersControllerTest < ActionDispatch::IntegrationTest assert_response :success end - test 'should get edit' do - get edit_player_url(@player) - assert_response :success - end - test 'should update player' do 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 test 'should destroy player' do