Remove where clause from followable button partial and rename followable_button partial to follow_button.

This commit is contained in:
Senén Rodero Rodríguez
2017-07-19 17:48:57 +02:00
parent c9a6630c94
commit 119a6b3397
7 changed files with 42 additions and 44 deletions

View File

@@ -1,11 +1,7 @@
module FollowablesHelper
def show_follow_action?(followable)
current_user && !followed?(followable)
end
def show_unfollow_action?(followable)
current_user && followed?(followable)
def followed?(user, followable)
Follow.followed?(user, followable)
end
def followable_type_title(followable_type)
@@ -31,10 +27,11 @@ module FollowablesHelper
followable.class.to_s.parameterize.gsub('-', '_')
end
private
def followed?(followable)
Follow.followed?(current_user, followable)
def find_or_build_follow(user, followable)
if followed?(user, followable)
return Follow.find_by(user: user, followable: followable)
end
Follow.new(user: user, followable: followable)
end
end