Skip to content

Commit

Permalink
Cleaned up nifty scaffold views, as well as renamed order to
Browse files Browse the repository at this point in the history
picks
  • Loading branch information
James Trowbridge committed May 5, 2010
1 parent 26e6b06 commit 621a32f
Show file tree
Hide file tree
Showing 25 changed files with 8,133 additions and 139 deletions.
30 changes: 15 additions & 15 deletions app/controllers/picks_controller.rb
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
class PicksController < ApplicationController
def index
@picks = Picks.all
@picks = Pick.all
end

def show
@picks = Picks.find(params[:id])
@pick = Pick.find(params[:id])
end

def new
@picks = Picks.new
@pick = Pick.new
end

def create
@picks = Picks.new(params[:picks])
if @picks.save
flash[:notice] = "Successfully created picks."
redirect_to @picks
@pick = Pick.new(params[:pick])
if @pick.save
flash[:notice] = "Successfully created pick."
redirect_to @pick
else
render :action => 'new'
end
end

def edit
@picks = Picks.find(params[:id])
@pick = Pick.find(params[:id])
end

def update
@picks = Picks.find(params[:id])
if @picks.update_attributes(params[:picks])
flash[:notice] = "Successfully updated picks."
redirect_to @picks
@pick = Pick.find(params[:id])
if @pick.update_attributes(params[:pick])
flash[:notice] = "Successfully updated pick."
redirect_to @pick
else
render :action => 'edit'
end
end

def destroy
@picks = Picks.find(params[:id])
@picks.destroy
flash[:notice] = "Successfully destroyed picks."
@pick = Pick.find(params[:id])
@pick.destroy
flash[:notice] = "Successfully destroyed pick."
redirect_to picks_url
end
end
30 changes: 15 additions & 15 deletions app/controllers/players_controller.rb
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
class PlayersController < ApplicationController
def index
@players = Players.all
@players = Player.all
end

def show
@players = Players.find(params[:id])
@player = Player.find(params[:id])
end

def new
@players = Players.new
@player = Player.new
end

def create
@players = Players.new(params[:players])
if @players.save
flash[:notice] = "Successfully created players."
redirect_to @players
@player = Player.new(params[:player])
if @player.save
flash[:notice] = "Successfully created player."
redirect_to @player
else
render :action => 'new'
end
end

def edit
@players = Players.find(params[:id])
@player = Player.find(params[:id])
end

def update
@players = Players.find(params[:id])
if @players.update_attributes(params[:players])
flash[:notice] = "Successfully updated players."
redirect_to @players
@player = Player.find(params[:id])
if @player.update_attributes(params[:player])
flash[:notice] = "Successfully updated player."
redirect_to @player
else
render :action => 'edit'
end
end

def destroy
@players = Players.find(params[:id])
@players.destroy
flash[:notice] = "Successfully destroyed players."
@player = Player.find(params[:id])
@player.destroy
flash[:notice] = "Successfully destroyed player."
redirect_to players_url
end
end
30 changes: 15 additions & 15 deletions app/controllers/teams_controller.rb
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
class TeamsController < ApplicationController
def index
@teams = Teams.all
@teams = Team.all
end

def show
@teams = Teams.find(params[:id])
@team = Team.find(params[:id])
end

def new
@teams = Teams.new
@team = Team.new
end

def create
@teams = Teams.new(params[:teams])
if @teams.save
flash[:notice] = "Successfully created teams."
redirect_to @teams
@team = Team.new(params[:team])
if @team.save
flash[:notice] = "Successfully created team."
redirect_to @team
else
render :action => 'new'
end
end

def edit
@teams = Teams.find(params[:id])
@team = Team.find(params[:id])
end

def update
@teams = Teams.find(params[:id])
if @teams.update_attributes(params[:teams])
flash[:notice] = "Successfully updated teams."
redirect_to @teams
@team = Team.find(params[:id])
if @team.update_attributes(params[:team])
flash[:notice] = "Successfully updated team."
redirect_to @team
else
render :action => 'edit'
end
end

def destroy
@teams = Teams.find(params[:id])
@teams.destroy
flash[:notice] = "Successfully destroyed teams."
@team = Team.find(params[:id])
@team.destroy
flash[:notice] = "Successfully destroyed team."
redirect_to teams_url
end
end
2 changes: 2 additions & 0 deletions app/helpers/picks_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module PicksHelper
end
18 changes: 15 additions & 3 deletions app/views/picks/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
<% form_for @picks do |f| %>
<% form_for @pick do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
<%= f.label :round %><br />
<%= f.text_field :round %>
</p>
<p>
<%= f.label :pick_number %><br />
<%= f.text_field :pick_number %>
</p>
<p>
<%= f.label :team_id %><br />
<%= f.text_field :team_id %>
</p>
<p>
<%= f.label :player_id %><br />
<%= f.text_field :player_id %>
</p>
<p><%= f.submit "Submit" %></p>
<% end %>
4 changes: 2 additions & 2 deletions app/views/picks/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<% title "Edit Picks" %>
<% title "Edit Pick" %>

<%= render :partial => 'form' %>

<p>
<%= link_to "Show", @picks %> |
<%= link_to "Show", @pick %> |
<%= link_to "View All", picks_path %>
</p>
26 changes: 11 additions & 15 deletions app/views/picks/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
<% title "Picks" %>
<% @picks.each do |pick| %>
<h1>
<%= pick.round %>
<%= pick.pick_number %>
<%= pick.team.name %>
<%= link_to "Show", pick %>
<%= link_to "Edit", edit_pick_path(pick) %>
<%= link_to "Destroy", pick, :confirm => 'Are you sure?', :method => :delete %>
</h1>
<% end %>

<table>
<tr>
<th>Name</th>
</tr>
<% for picks in @picks %>
<tr>
<td><%=h picks.name %></td>
<td><%= link_to "Show", picks %></td>
<td><%= link_to "Edit", edit_picks_path(picks) %></td>
<td><%= link_to "Destroy", picks, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>

<p><%= link_to "New Picks", new_picks_path %></p>
<p><%= link_to "New Pick", new_pick_path %></p>
2 changes: 1 addition & 1 deletion app/views/picks/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% title "New Picks" %>
<% title "New Pick" %>

<%= render :partial => 'form' %>

Expand Down
22 changes: 17 additions & 5 deletions app/views/picks/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
<% title "Picks" %>
<% title "Pick" %>

<p>
<strong>Name:</strong>
<%=h @picks.name %>
<strong>Round:</strong>
<%=h @pick.round %>
</p>
<p>
<strong>Pick Number:</strong>
<%=h @pick.pick_number %>
</p>
<p>
<strong>Team:</strong>
<%=h @pick.team_id %>
</p>
<p>
<strong>Player:</strong>
<%=h @pick.player_id %>
</p>

<p>
<%= link_to "Edit", edit_picks_path(@picks) %> |
<%= link_to "Destroy", @picks, :confirm => 'Are you sure?', :method => :delete %> |
<%= link_to "Edit", edit_pick_path(@pick) %> |
<%= link_to "Destroy", @pick, :confirm => 'Are you sure?', :method => :delete %> |
<%= link_to "View All", picks_path %>
</p>
22 changes: 21 additions & 1 deletion app/views/players/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
<% form_for @players do |f| %>
<% form_for @player do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<%= f.label :position %><br />
<%= f.text_field :position %>
</p>
<p>
<%= f.label :drafted %><br />
<%= f.check_box :drafted %>
</p>
<p>
<%= f.label :pick %><br />
<%= f.text_field :pick %>
</p>
<p>
<%= f.label :team_id %><br />
<%= f.text_field :team_id %>
</p>
<p>
<%= f.label :pick_id %><br />
<%= f.text_field :pick_id %>
</p>
<p><%= f.submit "Submit" %></p>
<% end %>
4 changes: 2 additions & 2 deletions app/views/players/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<% title "Edit Players" %>
<% title "Edit Player" %>

<%= render :partial => 'form' %>

<p>
<%= link_to "Show", @players %> |
<%= link_to "Show", @player %> |
<%= link_to "View All", players_path %>
</p>
22 changes: 16 additions & 6 deletions app/views/players/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,25 @@
<table>
<tr>
<th>Name</th>
<th>Position</th>
<th>Drafted</th>
<th>Pick</th>
<th>Team</th>
<th>Pick</th>
</tr>
<% for players in @players %>
<% for player in @players %>
<tr>
<td><%=h players.name %></td>
<td><%= link_to "Show", players %></td>
<td><%= link_to "Edit", edit_players_path(players) %></td>
<td><%= link_to "Destroy", players, :confirm => 'Are you sure?', :method => :delete %></td>
<td><%=h player.name %></td>
<td><%=h player.position %></td>
<td><%=h player.drafted %></td>
<td><%=h player.pick %></td>
<td><%=h player.team_id %></td>
<td><%=h player.pick_id %></td>
<td><%= link_to "Show", player %></td>
<td><%= link_to "Edit", edit_player_path(player) %></td>
<td><%= link_to "Destroy", player, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>

<p><%= link_to "New Players", new_players_path %></p>
<p><%= link_to "New Player", new_player_path %></p>
2 changes: 1 addition & 1 deletion app/views/players/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% title "New Players" %>
<% title "New Player" %>

<%= render :partial => 'form' %>

Expand Down
28 changes: 24 additions & 4 deletions app/views/players/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
<% title "Players" %>
<% title "Player" %>

<p>
<strong>Name:</strong>
<%=h @players.name %>
<%=h @player.name %>
</p>
<p>
<strong>Position:</strong>
<%=h @player.position %>
</p>
<p>
<strong>Drafted:</strong>
<%=h @player.drafted %>
</p>
<p>
<strong>Pick:</strong>
<%=h @player.pick %>
</p>
<p>
<strong>Team:</strong>
<%=h @player.team_id %>
</p>
<p>
<strong>Pick:</strong>
<%=h @player.pick_id %>
</p>

<p>
<%= link_to "Edit", edit_players_path(@players) %> |
<%= link_to "Destroy", @players, :confirm => 'Are you sure?', :method => :delete %> |
<%= link_to "Edit", edit_player_path(@player) %> |
<%= link_to "Destroy", @player, :confirm => 'Are you sure?', :method => :delete %> |
<%= link_to "View All", players_path %>
</p>
Loading

0 comments on commit 621a32f

Please sign in to comment.