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

@@ -0,0 +1,24 @@
<span class="js-follow">
<span class="followable-content">
<% unless followed?(current_user, follow.followable) %>
<%= link_to t('shared.follow'),
follows_path(followable_id: follow.followable.id,
followable_type: follow.followable.class.name),
method: :post, remote: true,
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>
</span>

View File

@@ -1,27 +0,0 @@
<span class="js-follow">
<span class="followable-content">
<% if show_follow_action? followable %>
<%= link_to t('shared.follow'),
follows_path(followable_id: followable.id,
followable_type: followable.class.name),
method: :post, remote: true,
title: follow_text(followable),
class: 'button hollow' %>
<% end %>
<% if show_unfollow_action? followable %>
<% follow = followable.follows.where(user: current_user).first %>
<%= link_to t('shared.unfollow'),
follow_path(follow),
method: :delete, remote: true,
title: unfollow_text(followable),
class: 'button hollow' %>
<% end %>
</span>
</span>

View File

@@ -1,2 +1,2 @@
App.Followable.update("<%= dom_id(@followable) %>",
"<%= j render('followable_button', followable: @followable) %>")
App.Followable.update("<%= dom_id(@follow.followable) %>",
"<%= j render('follow_button', follow: @follow) %>")