* Use constants for controller permitted params * User constants for controller set 2 Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
23 lines
546 B
Ruby
23 lines
546 B
Ruby
class PollSkipsController < ApplicationController
|
|
before_action :authenticate_user!, only: %i[create]
|
|
|
|
POLL_SKIPS_PERMITTED_PARAMS = %i[poll_id].freeze
|
|
|
|
def create
|
|
poll = Poll.find(poll_skips_params[:poll_id])
|
|
poll.poll_skips.create_or_find_by(user_id: current_user.id)
|
|
|
|
render json: {
|
|
voting_data: poll.voting_data,
|
|
poll_id: poll.id,
|
|
user_vote_poll_option_id: nil,
|
|
voted: false
|
|
}
|
|
end
|
|
|
|
private
|
|
|
|
def poll_skips_params
|
|
params.require(:poll_skip).permit(POLL_SKIPS_PERMITTED_PARAMS)
|
|
end
|
|
end
|