wired up vote ux

This commit is contained in:
Mark Moser
2016-11-20 11:24:17 -06:00
parent 5ef7f82dbf
commit 74b2415b91
6 changed files with 75 additions and 22 deletions

View File

@ -17,7 +17,7 @@ class Candidate < ApplicationRecord
validates :test_hash, uniqueness: true, presence: true
enum review_status: {
# pending: 0,
pending: 0,
approved: 1,
declined: 2
}

View File

@ -47,6 +47,13 @@ class User < ApplicationRecord
candidate.update_attribute(:review_status, :declined) if vote.save
end
def my_vote candidate
candidate = Candidate.find(candidate.to_i)
my_votes = votes.find_by(candidate_id: candidate.id)
my_votes.nil? ? "undecided" : my_votes.votes
end
# Roles
def admin?
'admin' == role