Module: Voteable

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

Overview

Using concerns

Instance Method Summary collapse

Instance Method Details

#down_votesObject



18
19
20
# File 'lib/voteable_nathan.rb', line 18

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

#total_votesObject



10
11
12
# File 'lib/voteable_nathan.rb', line 10

def total_votes
  up_votes  - down_votes
end

#up_votesObject



14
15
16
# File 'lib/voteable_nathan.rb', line 14

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