about summary refs log tree commit diff stats
path: root/app/models/concerns
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/concerns')
-rw-r--r--app/models/concerns/votable.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/concerns/votable.rb b/app/models/concerns/votable.rb index ba6e6d5..40b3a2a 100644 --- a/app/models/concerns/votable.rb +++ b/app/models/concerns/votable.rb
@@ -39,5 +39,13 @@ module Votable
39 save! 39 save!
40 end 40 end
41 end 41 end
42
43 def like!(url, name)
44 return false unless votes.where(liker_url: url).empty?
45
46 votes.create(liker_url: url, liker_name: name, upvote: 1).save
47 self.upvotes += 1
48 save!
49 end
42 end 50 end
43end 51end