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