From 824228fe1be992cae59d532d0ec13073048d3fc3 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Thu, 15 Oct 2015 21:38:46 +0300 Subject: [PATCH] Add percentage --- app/controllers/home_controller.rb | 1 + app/views/home/_talk.html.erb | 1 + app/views/home/ratings.html.erb | 1 + 3 files changed, 3 insertions(+) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index ac1cfab..3200952 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -5,6 +5,7 @@ class HomeController < ApplicationController def ratings @talks = Talk.ordered_by_rating @ratings = Ratings.new + @votes_count = TalkPreference.count end def export diff --git a/app/views/home/_talk.html.erb b/app/views/home/_talk.html.erb index c7590ba..8b90eae 100644 --- a/app/views/home/_talk.html.erb +++ b/app/views/home/_talk.html.erb @@ -4,4 +4,5 @@ <%= talk.title %> <%= talk.subtitle %> <%= @ratings[talk.id] %> + <%= "%.2f%" % Rational(100 * @ratings[talk.id], @votes_count).to_f %> diff --git a/app/views/home/ratings.html.erb b/app/views/home/ratings.html.erb index 69161b5..d11a174 100644 --- a/app/views/home/ratings.html.erb +++ b/app/views/home/ratings.html.erb @@ -6,6 +6,7 @@ Title Subtitle Votes + %