From da93edc70f83c98228f29fc195c75f06634aa670 Mon Sep 17 00:00:00 2001 From: notmarkmiranda Date: Mon, 11 Feb 2019 19:14:50 -0700 Subject: [PATCH] Closes #76 --- app/controllers/user_stats_controller.rb | 2 ++ app/decorators/player_decorator.rb | 7 +++++++ app/views/user_stats/show.html.erb | 7 +++---- spec/decorators/player_decorator_spec.rb | 15 +++++++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/app/controllers/user_stats_controller.rb b/app/controllers/user_stats_controller.rb index 64620f8..c028eb2 100644 --- a/app/controllers/user_stats_controller.rb +++ b/app/controllers/user_stats_controller.rb @@ -6,10 +6,12 @@ def show @players = @user.players.joins(:game) .where('games.season_id = ?', params[:season]) .order('games.date DESC') + .decorate else @season = nil @players = @user.players.joins(:game) .order('games.date DESC') + .decorate end end end diff --git a/app/decorators/player_decorator.rb b/app/decorators/player_decorator.rb index 9ad0025..4348b89 100644 --- a/app/decorators/player_decorator.rb +++ b/app/decorators/player_decorator.rb @@ -27,6 +27,13 @@ def name_with_place end end + def place_and_score + return unless object.finishing_place && object.score + h.content_tag(:div, class: 'caption-text text-danger') do + "#{object.finishing_place.ordinalize} place out of #{h.pluralize(object.game_players_count, 'player')} | Score: #{object.score}" + end + end + def score_text additional_expense = object.has_additional_expense? if game_object.completed? diff --git a/app/views/user_stats/show.html.erb b/app/views/user_stats/show.html.erb index 48165cd..ec06138 100644 --- a/app/views/user_stats/show.html.erb +++ b/app/views/user_stats/show.html.erb @@ -40,10 +40,9 @@