From 8a778611651106d3a35e5201aec0f1eae93697f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Tue, 27 Dec 2016 17:46:24 +0100 Subject: [PATCH] adds helper for booth and date selectors --- app/helpers/polls_helper.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/helpers/polls_helper.rb b/app/helpers/polls_helper.rb index 594a20efe..ed39f44e5 100644 --- a/app/helpers/polls_helper.rb +++ b/app/helpers/polls_helper.rb @@ -20,4 +20,25 @@ module PollsHelper end end + def poll_dates_select_options(poll) + options = [] + (poll.starts_at.to_date..poll.ends_at.to_date).each do |date| + options << [l(date), l(date)] + end + options_for_select(options) + end + + def poll_booths_select_options(poll) + options = [] + poll.booths.each do |booth| + options << [booth_name_with_location(booth), booth.id] + end + options_for_select(options) + end + + def booth_name_with_location(booth) + location = booth.location.blank? ? "" : " (#{booth.location})" + booth.name + location + end + end \ No newline at end of file