Module: Voteable

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

Overview

Using Concerns

Instance Method Summary collapse

Instance Method Details

#downvoteObject



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

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

#total_votesObject



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

def total_votes
  self.upvote - self.downvote
end

#upvoteObject



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

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