From 2a6ca7b0ffd84c20df804ac829afc3fe2daec9c1 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Thu, 6 Aug 2015 07:41:20 +0300 Subject: [PATCH] Fix ordering for event.average_voting in events#index --- app/models/event.rb | 2 +- app/views/admin/events/index.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index 7f5d9aa8..7cd75a89 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -77,7 +77,7 @@ class Event < ActiveRecord::Base @total_rating = @total_rating + vote.rating end @total = votes.size - number_with_precision(@total_rating / @total.to_f, precision: 2, strip_insignificant_zeros: true) + @total_rating > 0 ? number_with_precision(@total_rating / @total.to_f, precision: 2, strip_insignificant_zeros: true) : 0 end def submitter diff --git a/app/views/admin/events/index.html.haml b/app/views/admin/events/index.html.haml index b796da61..1f591268 100644 --- a/app/views/admin/events/index.html.haml +++ b/app/views/admin/events/index.html.haml @@ -42,7 +42,7 @@ =link_to event.title, admin_conference_event_path(@conference.short_title, event) - if @conference.call_for_paper && @conference.call_for_paper.rating && @conference.call_for_paper.rating > 0 - %td.col-md-1 + %td.col-md-1{'data-order' => "#{event.average_rating}"} - if event.average_rating.to_f > 0 #{event.average_rating}/#{@conference.call_for_paper.rating} %br