Commit 25ece4ec authored by April Guian's avatar April Guian

kulang ng @

parent 2b896259
......@@ -16,7 +16,7 @@
<% if current_user.id == @user.id %>
<h4> <%= link_to "You haven't voted for any candidates yet. Vote Now!", "/voting/votes" %> </h4>
<%else%>
<h4> <%=user.full_name %> has not casted their votes yet %> </h4>
<h4> <%=@user.full_name %> has not casted their votes yet %> </h4>
<%end%>
</center>
<%end%>
......
def vote
voted_for = false
@position = Position.find(params[:position_id])
#@candidate = params[:candidate_id]
#@pos = params[:id]
#@candidate = Candidate.new
#if current_user voted_for candidate.position
#Position.find(@position).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|
c.votes.each do |v|
if current_user.id == v.user_id
voted_for = true
end
end
end
#@post = Post.find(params[:post_id])
#@post.liked_by current_user
#respond_to do |format|
# format.html {redirect_to :back }
#end
#@position.voted_for current_user
if position.voted_for == false
# @vote = Vote.new
redirect_to new_voting_vote_path(@vote.id)
else
redirect_to admin_candidates_path
end
end
if position.voted_for == false
redirect_to new_voting_vote_path(@vote.id)
else
redirect_to admin_candidates_path, notice: "Sorry, you can only vote on a position and candidate once."
end
---------------
votes = Vote.all
voted_for = false
positions = Position.all
candidates = Candidate.all
@position = Position.find(params[:id])
candidates(@position).each do |c|
c.votes.each do |v|
if current_user.id == v.user_id
voted_for = true
end
end
end
if voted_for == false
#@votes= Vote.all
@candidate = Candidate.find(params[:id])
#@vote = Vote.new
redirect_to new_voting_vote_path(@candidate)
else
redirect_to admin_candidates_path
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