Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Commit

Permalink
Add new winners view
Browse files Browse the repository at this point in the history
  • Loading branch information
godfathersama committed Nov 6, 2014
1 parent 313c112 commit 8f30507
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/controllers/static_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ def index

def updates
end

def winner
@user = User.where('username != "mamacias"').order('score DESC')
end
end
13 changes: 13 additions & 0 deletions app/views/static/winner.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<h1>The results are in!</h1>

<% if @user && @user.first.attempts.first %>
<h2>First place</h2>
<p>
<b>Username:</b> <%= @user.first.username %><br/>
<b>Score:</b> <%= @user.first.score %><br/>
<b>Attempt:</b> <%= @user.first.attempts.order('score DESC, created_at ASC').first.attempt %><br/>
</p>
<% else %>
<h2>No participants or attempts</h2>
<% end %>

0 comments on commit 8f30507

Please sign in to comment.