Remove where clause from followable button partial and rename followable_button partial to follow_button.
This commit is contained in:
24
app/views/follows/_follow_button.html.erb
Normal file
24
app/views/follows/_follow_button.html.erb
Normal 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>
|
||||
@@ -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>
|
||||
@@ -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) %>")
|
||||
|
||||
Reference in New Issue
Block a user