adds helper for booth and date selectors

This commit is contained in:
Juanjo Bazán
2016-12-27 17:46:24 +01:00
parent 77c2d61c64
commit 8a77861165

View File

@@ -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