5.9 added the possibility to exit a beerclub

This commit is contained in:
Aaro Koivukangas
2023-11-20 15:29:28 +02:00
parent 7bdfb41058
commit 03232ae423
2 changed files with 7 additions and 2 deletions
+2 -1
View File
@@ -54,10 +54,11 @@ class MembershipsController < ApplicationController
# DELETE /memberships/1 or /memberships/1.json
def destroy
@user = @membership.user
@membership.destroy
respond_to do |format|
format.html { redirect_to memberships_url, notice: "Membership was successfully destroyed." }
format.html { redirect_to user_path(@user), notice: "Successfully exited the group." }
format.json { head :no_content }
end
end
+5 -1
View File
@@ -11,7 +11,11 @@
<%= form.submit "Join the beer club" %>
<% end %>
<% else %>
<p>You are already in this group</p>
<%= form_with(model: @membership, method: :delete) do |form| %>
<%= form.hidden_field :beer_club_id, value: @beerclub.id %>
<%= form.hidden_field :user_id, value: current_user.id %>
<%= form.submit "End the membership" %>
<% end %>
<% end %>
<% else %>