From f0d1eb3d51ac4343ad66bd97c01592499a373071 Mon Sep 17 00:00:00 2001 From: Jesse HK Date: Sun, 7 Sep 2014 14:42:25 -0400 Subject: [PATCH] Show names of who voted for projects on finalist page. --- app/models/project.rb | 11 +++++++++++ app/views/finalists/index.html.erb | 2 ++ 2 files changed, 13 insertions(+) diff --git a/app/models/project.rb b/app/models/project.rb index 9be65d32..0cd45564 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -60,6 +60,17 @@ def self.by_vote_count order("vote_count DESC") end + def vote_names + names = ""; + users.each_with_index do |user, index| + names << user.name + if index != users.size - 1 + names << ", " + end + end + return names + end + def self.recent_winners subquery = select("DISTINCT ON (chapter_id) projects.*").where("projects.funded_on IS NOT NULL").order(:chapter_id, :funded_on).reverse_order select("*").from("(#{subquery.to_sql}) AS distinct_chapters").order(:funded_on).reverse_order diff --git a/app/views/finalists/index.html.erb b/app/views/finalists/index.html.erb index 0d24630b..92559141 100644 --- a/app/views/finalists/index.html.erb +++ b/app/views/finalists/index.html.erb @@ -39,12 +39,14 @@ <%= t ".table.title" %> <%= t ".table.id " %> <%= t ".table.votes" %> + Who voted? <% @projects.each do |project| %> <%= link_to project.title, chapter_project_path(project.chapter, project) %> <%= project.id %> <%= project.vote_count %> + <%= project.vote_names %> <% end %>