bug fixing using cursor

This commit is contained in:
Stefan Tollkühn
2025-09-10 13:45:29 +02:00
parent 06bea4cf46
commit 59e63cee2f
6 changed files with 15 additions and 6 deletions

View File

@@ -49,8 +49,15 @@ class ClientsController < ApplicationController
# DELETE /clients/1 or /clients/1.json
def destroy
@client.destroy!
if @client.referenced_count > 0
respond_to do |format|
format.html { redirect_to clients_path, alert: "Client is referenced by subprojects and cannot be deleted." }
format.json { render json: { error: "Client has references" }, status: :unprocessable_entity }
end
return
end
@client.destroy!
respond_to do |format|
format.html { redirect_to clients_path, status: :see_other, notice: "Client was successfully destroyed." }
format.json { head :no_content }