Commit f07015a9 authored by Kristoff Sison's avatar Kristoff Sison

added voting based on cadidate id

parent 5e8443b6
class ElectionController < ApplicationController
def vote
if Vote.exists?(candidate_id: params[:id], user_id: current_user.id)
render "candidates/show.html.erb"
else
redirect_to new_vote_path
end
end
end
\ No newline at end of file
...@@ -7,4 +7,5 @@ ...@@ -7,4 +7,5 @@
<li>Female Voters: <%= @votes_female.size %></li> <li>Female Voters: <%= @votes_female.size %></li>
</ul> </ul>
<%= link_to "Votes for Candidate", "/election/vote/#{@candidate.id}" %>
<%= link_to "Back to Candidates", admin_candidates_path %> <%= link_to "Back to Candidates", admin_candidates_path %>
\ No newline at end of file
...@@ -16,6 +16,7 @@ Rails.application.routes.draw do ...@@ -16,6 +16,7 @@ Rails.application.routes.draw do
get'/party_lists/index', to: "party_lists#index" get'/party_lists/index', to: "party_lists#index"
get'/votes/user_profile', to: "votes#profile" get'/votes/user_profile', to: "votes#profile"
get'/votes/index', to: "votes#index" get'/votes/index', to: "votes#index"
get'/election/vote/:id', to: "election#vote"
post'/checkout', to: 'votes#checkout', as: :checkout post'/checkout', to: 'votes#checkout', as: :checkout
end end
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