candidate.rb 459 Bytes
Newer Older
Galen Evilla's avatar
Galen Evilla committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
class Candidate < ApplicationRecord
  belongs_to :position
  has_many :votes, dependent: :destroy
  accepts_nested_attributes_for :votes

  validates :last_name, presence: true
  validates :first_name, presence: true

  def full_name
    "#{ self.first_name } #{ self.last_name }"
  end

  #def male_votes
  #  votes.select { |vote| vote.user.gender == 'male' }
  #end

  #def female_votes
  #  votes.select { |vote| vote.user.gender == 'female' }
  #end
end