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

Individual Task Guian

parent 389ec497
...@@ -2,31 +2,29 @@ class ElectionController < ApplicationController ...@@ -2,31 +2,29 @@ class ElectionController < ApplicationController
before_action :authenticate_user! before_action :authenticate_user!
def vote def vote
@positions = Position.all
@position = Position.find(params[:id]) @candidates = Candidate.all
@candidates = Candidate.all @positions = Position.all
@user = User.find(params[:id]) @candidate = Candidate.find(params[:id])
#@votes = Vote.all @user = User.find(params[:id])
@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
#@position.candidates.each do |c| if current_user.id == @user
# c.votes.each do |v| redirect_to new_voting_vote_path(@candidate.id)
# if current_user.id == v.user_id else
# voted_for = true redirect_to voting_votes_path
# end end
# end
# end
if current_user.id == @user
#if voted_for == false
redirect_to new_voting_vote_path
else
redirect_to voting_votes_path
end
end
def vote_params
params.require(:vote).permit!
end end
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