Skip to content

Instantly share code, notes, and snippets.

@rodloboz
Created April 27, 2019 01:15
Show Gist options
  • Save rodloboz/1f50455fac1edb151e4ba19637d6b613 to your computer and use it in GitHub Desktop.
Save rodloboz/1f50455fac1edb151e4ba19637d6b613 to your computer and use it in GitHub Desktop.
<div id="follow-btn">
<% if current_user.is_following?(user) %>
<%= link_to user_unfollow_path(user.username), method: :delete,
data: {
action: 'ajax:success->follow#update'
},
remote: true do
%>
<button class="btn btn-blue ml-4">Unfollow</button>
<% end %>
<% else %>
<%= link_to user_follow_path(user.username), method: :post,
data: {
action: 'ajax:success->follow#update'
},
remote: true do
%>
<button class="btn btn-blue ml-4">Follow</button>
<% end %>
<% end %>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment