Module: VoteablePeter
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/voteable_peter.rb
Instance Method Summary collapse
Instance Method Details
#down_votes ⇒ Object
13 14 15 |
# File 'lib/voteable_peter.rb', line 13 def down_votes self.votes.where(vote: false).size end |
#total_votes ⇒ Object
5 6 7 |
# File 'lib/voteable_peter.rb', line 5 def total_votes up_votes - down_votes end |
#up_votes ⇒ Object
9 10 11 |
# File 'lib/voteable_peter.rb', line 9 def up_votes self.votes.where(vote: true).size end |
#user_voted? ⇒ Boolean
17 18 19 |
# File 'lib/voteable_peter.rb', line 17 def user_voted? self.votes.where(user_id: current_user.id).present? end |