app/views/organizations/_petition_button.html.erb
<% if current_user %>
<% petition = current_user.petitions.where(organization_id: organization.id).last %>
<% if member = Member.where(user: current_user, organization: organization).first %>
<%= link_to t('users.user_rows.delete_membership'),
member,
method: :delete,
data: { confirm: t('users.user_rows.sure_delete', organization_name: organization.name) },
class: 'btn btn-danger' %>
<% elsif petition && !current_user.was_member?(petition) %>
<span class="badge"><%= petition.status %></span>
<% else %>
<%= link_to t('petitions.apply'),
petitions_path(user_id: current_user.id, organization_id: organization.id),
method: :post,
class: 'btn btn-default' %>
<% end %>
<% end %>