fix(locale): Handle blank locale submission gracefully (#1876)

Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com>
This commit is contained in:
sentry[bot]
2026-05-24 15:13:49 +02:00
committed by GitHub
parent c7c63a50a7
commit c93193cfbc
2 changed files with 20 additions and 13 deletions

View File

@@ -27,21 +27,27 @@ class UsersController < ApplicationController
end
else
was_ai_enabled = @user.ai_enabled
@user.update!(user_params.except(:redirect_to, :delete_profile_image))
@user.profile_image.purge if should_purge_profile_image?
if @user.update(user_params.except(:redirect_to, :delete_profile_image))
@user.profile_image.purge if should_purge_profile_image?
# Add a special notice if AI was just enabled or disabled
notice = if !was_ai_enabled && @user.ai_enabled
"AI Assistant has been enabled successfully."
elsif was_ai_enabled && !@user.ai_enabled
"AI Assistant has been disabled."
# Add a special notice if AI was just enabled or disabled
notice = if !was_ai_enabled && @user.ai_enabled
"AI Assistant has been enabled successfully."
elsif was_ai_enabled && !@user.ai_enabled
"AI Assistant has been disabled."
else
t(".success")
end
respond_to do |format|
format.html { handle_redirect(notice) }
format.json { head :ok }
end
else
t(".success")
end
respond_to do |format|
format.html { handle_redirect(notice) }
format.json { head :ok }
respond_to do |format|
format.html { redirect_to settings_profile_path, alert: @user.errors.full_messages.to_sentence }
format.json { render json: { errors: @user.errors.full_messages }, status: :unprocessable_entity }
end
end
end
end