An ActiveRecord::InvalidForeignKey occurred in service_visits#destroy:

related ticket https://redmine.bikelink.org/issues/2483

An ActiveRecord::InvalidForeignKey occurred in service_visits#destroy:

 PG::ForeignKeyViolation: ERROR:  update or delete on table "service_visits" violates foreign key constraint "fk_rails_109371c3f2" on table "performed_service_records"
DETAIL:  Key (id)=(6873) is still referenced from table "performed_service_records".

 app/controllers/service_visits_controller.rb:21:in `destroy'


-------------------------------
Request:
-------------------------------

 * URL        : https://bikelink.org/service_visits/6873
 * HTTP Method: DELETE
 * IP address : 98.35.154.160
 * Parameters : {"_method"=>"delete", "authenticity_token"=>"T3ZG3ZxM0NyR1IPtYJtDATWzLnDEMo6POcf/9c5T0v5XteSt18kKBeReYV9UFfjYh60tCQBYvU5a6weq/hcNig==", "controller"=>"service_visits", "action"=>"destroy", "id"=>"6873"}
 * Timestamp  : 2021-05-03 17:11:35 UTC
 * Server : www-4.internal.bikelink.org
   * Rails root : /var/www/bikelink
 * Process: 2248

-------------------------------
Session:
-------------------------------

 * session id: [FILTERED]
 * data: {"session_id"=>"32a3d28fd5f94ac7ad29c220c4e8e4d6",
  "warden.user.person.key"=>[[31069], "sTS8Ej46w_WwHcSCjmQv"],
  "_csrf_token"=>"ViT6HwY5LDfP4jN+Re05hE1BL9F5n33dXMM9wq8lXxU="}

-------------------------------
Backtrace:
-------------------------------

 app/controllers/service_visits_controller.rb:21:in `destroy'
Znovu načíst