diaspora/app/controllers/poll_participations_controller.rb
2018-12-16 11:06:27 -05:00

24 lines
649 B
Ruby

# frozen_string_literal: true
class PollParticipationsController < ApplicationController
before_action :authenticate_user!
def create
poll_participation = poll_service.vote(params[:post_id], params[:poll_answer_id])
respond_to do |format|
format.mobile { redirect_to stream_path }
format.json { render json: poll_participation, :status => 201 }
end
rescue ActiveRecord::RecordInvalid
respond_to do |format|
format.mobile { redirect_to stream_path }
format.json { head :forbidden }
end
end
private
def poll_service
@poll_service ||= PollParticipationService.new(current_user)
end
end