Files
nairobi/app/controllers/polls_controller.rb
Juanjo Bazán 6bc4f5b307 adds Poll::Answer model for web users
PartialResults is kept for booth results
2017-01-25 12:46:44 +01:00

22 lines
536 B
Ruby

class PollsController < ApplicationController
load_and_authorize_resource
has_filters %w{current expired incoming}
def index
@polls = @polls.send(@current_filter).sort_for_list.page(params[:page])
end
def show
@questions = @poll.questions.for_render.sort_for_list
@answers_by_question_id = {}
poll_answers = Poll::Answer.by_question(@poll.question_ids).by_author(current_user.try(:id))
poll_answers.each do |answer|
@answers_by_question_id[answer.question_id] = answer.answer
end
end
end