Skip to content

Commit b784ef9

Browse files
committed
Fix membership edit crash when only complements update is allowed
`can_member_update?` returns true when complement updates are allowed, but the membership edit page only handles depot changes. When depot update is disabled, the form renders empty and submitting it raises `ActionController::ParameterMissing: param is missing or the value is empty or invalid: membership`. Guard both the edit link and the controller action with `can_member_update_depot?`.
1 parent 7d67f55 commit b784ef9

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

app/controllers/members/memberships_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def load_membership
2626
end
2727

2828
def ensure_member_can_update_membership!
29-
redirect_to members_memberships_path unless @membership.can_member_update?
29+
redirect_to members_memberships_path unless @membership.can_member_update? && @membership.can_member_update_depot?
3030
end
3131

3232
def membership_params

app/views/members/memberships/_membership.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<h2>
33
<%= membership.fiscal_year %>
44

5-
<% if membership.can_member_update? %>
5+
<% if membership.can_member_update? && membership.can_member_update_depot? %>
66
<%= link_to edit_members_membership_path(membership), title: t(".edit"), class: "ml-1 p-3" do %>
77
<%= icon "pencil-square", class: "mb-1 inline size-5 text-gray-400 dark:text-gray-500 hover:text-green-500 dark:hover:text-green-500" %>
88
<% end %>

0 commit comments

Comments
 (0)