Skip to content
Snippets Groups Projects
Commit 23077147 authored by Mauricio Giacomini Girardello's avatar Mauricio Giacomini Girardello
Browse files

adding concerns methods

parent 29b358d0
No related branches found
No related tags found
No related merge requests found
......@@ -5,4 +5,16 @@ module Followable
has_many :follows, as: :followable
end
def follow(user)
Follow.create(user: user, followable: self)
end
def unfollow(user)
Follow.where(user: user, followable: self).destroy_all
end
def following?(user)
!follows.where(user: user).blank?
end
end
\ No newline at end of file
......@@ -8,4 +8,16 @@ module Sociable
has_many :shares, as: :shareable
end
def liked?(user)
!likes.where(user: user).blank?
end
def like(user)
Like.create(user: user, likeable: self)
end
def dislike(user)
Like.where(user: user, likeable: self).destroy_all
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment