Module: Voteable

Extended by:
ActiveSupport::Concern
Defined in:
lib/voteable.rb

Instance Method Summary collapse

Instance Method Details

#down_votesObject



16
17
18
# File 'lib/voteable.rb', line 16

def down_votes
  self.votes.where(vote: false).count
end

#total_votesObject



8
9
10
# File 'lib/voteable.rb', line 8

def total_votes
  up_votes - down_votes
end

#up_votesObject



12
13
14
# File 'lib/voteable.rb', line 12

def up_votes
  self.votes.where(vote: true).count
end