docbrown/app/controllers/poll_skips_controller.rb
praveen raghav ns 4b8576aec3
Use constants for Permitted params in controller (#14895)
* Use constants for controller permitted params

* User constants for controller set 2

Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
2021-10-05 09:00:14 -04:00

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