From 3687a7708c7605e8b4c4da2a6f0d553ad47fe7bd Mon Sep 17 00:00:00 2001 From: Justin Miller <16829344+jmilljr24@users.noreply.github.com> Date: Fri, 6 Feb 2026 19:15:56 -0500 Subject: [PATCH] fix user update mising facilitator param --- app/models/user.rb | 8 ++++++++ app/views/users/_form.html.erb | 18 +++++------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 6c80a3dbf..ac1a40aad 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -50,6 +50,7 @@ class User < ApplicationRecord # Validations validates :email, presence: true, uniqueness: { case_sensitive: false } validate :time_zone_must_be_valid, if: :time_zone_changed? + validate :facilitator_id_must_be_present_if_previously_set, on: :update validates_associated :project_users # Search Cop @@ -181,6 +182,13 @@ def time_zone_must_be_valid errors.add(:time_zone, "is not a valid time zone") end + def facilitator_id_must_be_present_if_previously_set + return unless facilitator_id_was.present? + return if facilitator_id.present? + + errors.add(:facilitator_id, "cannot be removed once set") + end + def set_default_values self.inactive = false if inactive.nil? self.confirmed = true if confirmed.nil? diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index 5291b74e3..9de47b1f3 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -1,8 +1,6 @@ <%= simple_form_for @user, html: { multipart: true, class: "space-y-8" } do |f| %> <%= render "shared/errors", resource: user if user.errors.any? %> - - <%= f.hidden_field :facilitator_id, value: params[:facilitator_id] %> - + <%= f.hidden_field :facilitator_id, value: @facilitator&.id || f.object.facilitator_id || params[:facilitator_id] %>
@@ -28,7 +26,6 @@

-
<% end %> <% end %> -
<% if current_user.super_user? %>
@@ -73,7 +69,7 @@ data-controller="confirm-email" data-confirm-email-user-id-value="<%= @user.id %>" data-action="click->confirm-email#confirm" - class="btn btn-sm bg-blue-600 hover:bg-blue-700 text-white border-blue-600"> + class="btn btn-sm bg-blue-600 hover:bg-blue-700 text-white border-blue-600"> Manually confirm email
@@ -86,9 +82,9 @@ Email <%= email_confirmation_icon(@user) %>
- - <%= f.object.email.presence || @facilitator&.email %> - + + <%= f.object.email.presence || @facilitator&.email %> +

Only editable by admins @@ -107,7 +103,6 @@ <% end %>

- <% if current_user.super_user? %>
@@ -117,7 +112,6 @@
-
<%= f.input :time_zone, @@ -129,12 +123,10 @@ input_html: { class: "w-full" }, wrapper_html: { class: "w-full max-w-md" } %>
-
<%= render "toggle_lock_button", user: @user %> - <% if f.object.persisted? && allowed_to?(:destroy?, f.object) %> <%= link_to "Delete", @user, method: :delete, class: "btn btn-danger-outline", data: { confirm: "Are you sure you want to delete?" } %>