Module: Votable

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

Overview

Using Concerns

Instance Method Summary collapse

Instance Method Details

#down_votesObject



17
18
19
# File 'lib/votable_henry.rb', line 17

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

#total_votesObject



9
10
11
# File 'lib/votable_henry.rb', line 9

def total_votes
  self.up_votes - self.down_votes
end

#up_votesObject



13
14
15
# File 'lib/votable_henry.rb', line 13

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