Skip to content

Instantly share code, notes, and snippets.

@dwradcliffe
Created July 5, 2012 15:17
Show Gist options
  • Save dwradcliffe/3054312 to your computer and use it in GitHub Desktop.
Save dwradcliffe/3054312 to your computer and use it in GitHub Desktop.
class Player < ActiveRecord::Base
def salary_valid_for_year? year
send("s#{year}") != 0 && send("status#{year}") != 0 && !send("status#{year}").nil?
end
def salary_for_year year
send("s#{year}")
end
def salary_notes_for_year year
send("status#{year}").notes
end
end
<%= link_to 'Back', players_path %>
<% content_for :sidebar do %>
<ul>
<li><% @title %></li>
</ul>
<% end %>
<br>
<p><h3>
<%= "#{@player.first_name} #{@player.last_name}" %> | <%= @player.namenick %> | <%= "#{@player.birthcity}, #{@player.birthstate}" %> | <%= @player.team.name unless @team.nil? %></h3>
</p>
<p>
Bats: <%= @player.bats%>
Throws: <%= @player.throws%><br>
Weight: <%= @player.weight%> lbs
Height: <%= @player.height%> inches<br>
Debut: <%= @player.debut%><br>
Birthday: <%= @player.birthmonth%>/<%= @player.birthday%>/<%= @player.birthyear%><br>
Facebook: <%= @player.facebook%><br>
Twitter: <%= @player.twitter%><br>
Agent: <%= link_to @player.agent.name, agents_path(@agent) unless @agent.nil? %><br>
</p>
<table id="myTable" class="tablesorter">
<thead>
<tr>
<th>Year</th>
<th>Salary</th>
<th>Salary Notes</th>
</tr>
</thead>
<tbody>
<% (1985..2024).each do |year| %>
<tr>
<% if @player.salary_valid_for_year?(year) %>
<td><%= year %></td>
<td>$<%= number_with_delimiter(@player.salary_for_year(year), :delimiter => ',') %></td>
<td><%= @player.salary_notes_for_year(year) %></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
<script> $(document).ready(function()
{
$("table").tablesorter();
}
); </script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment