Files
nairobi/app/controllers/polls/questions_controller.rb
2017-10-03 19:11:39 +02:00

19 lines
472 B
Ruby

class Polls::QuestionsController < ApplicationController
load_and_authorize_resource :poll
load_and_authorize_resource :question, class: 'Poll::Question'
has_orders %w{most_voted newest oldest}, only: :show
def answer
answer = @question.answers.find_or_initialize_by(author: current_user)
answer.answer = params[:answer]
answer.save!
answer.record_voter_participation
@answers_by_question_id = {@question.id => params[:answer]}
end
end