Module: Voteable

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

Instance Method Summary collapse

Instance Method Details

#downvotesObject



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

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

#total_votesObject



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

def total_votes
  self.upvotes - self.downvotes  
end

#upvotesObject



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

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