Commit 59a144cc authored by April Guian's avatar April Guian

Individual Task Guian

parent 389ec497
......@@ -2,31 +2,29 @@ class ElectionController < ApplicationController
before_action :authenticate_user!
def vote
@positions = Position.all
@position = Position.find(params[:id])
@candidates = Candidate.all
@positions = Position.all
@candidate = Candidate.find(params[:id])
@user = User.find(params[:id])
#@votes = Vote.all
#@position.candidates.each do |c|
@pos = params[:id]
#Position.find(@pos).candidates.each do |c|
# c.votes.each do |v|
# if current_user.id == v.user_id
# voted_for = true
# end
# end
# end
#end
if current_user.id == @user
#if voted_for == false
redirect_to new_voting_vote_path
redirect_to new_voting_vote_path(@candidate.id)
else
redirect_to voting_votes_path
end
end
def vote_params
params.require(:vote).permit!
end
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment