Remove complex methods from follow model. Create instance method followed_by? on followable model concern. Some code improvements.

This commit is contained in:
Senén Rodero Rodríguez
2017-07-19 21:50:37 +02:00
parent dec7d2d2b5
commit b7bce2e699
5 changed files with 16 additions and 31 deletions

View File

@@ -1,7 +1,15 @@
<span class="js-follow">
<span class="followable-content">
<% unless followed?(current_user, follow.followable) %>
<% if follow.followable.followed_by?(current_user) %>
<%= link_to t('shared.unfollow'),
follow_path(follow),
method: :delete, remote: true,
title: unfollow_text(follow.followable),
class: 'button hollow' %>
<% else %>
<%= link_to t('shared.follow'),
follows_path(followable_id: follow.followable.id,
@@ -10,14 +18,6 @@
title: follow_text(follow.followable),
class: 'button hollow' %>
<% else %>
<%= link_to t('shared.unfollow'),
follow_path(follow),
method: :delete, remote: true,
title: unfollow_text(follow.followable),
class: 'button hollow' %>
<% end %>
</span>