PG::ForeignKeyViolation: ERROR: update or delete on table "trouble_tickets" violates foreign key

An ActiveRecord::InvalidForeignKey occurred in trouble_tickets#destroy:

 PG::ForeignKeyViolation: ERROR:  update or delete on table "trouble_tickets" violates foreign key constraint "service_photos_trouble_ticket_id_fkey" on table "photos"
DETAIL:  Key (id)=(12932) is still referenced from table "photos".

 app/controllers/trouble_tickets_controller.rb:28:in `destroy'


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

 * URL        : https://www.bikelink.org/trouble_tickets/12932
 * HTTP Method: DELETE
 * IP address : 71.204.158.129
 * Parameters : {"_method"=>"delete", "authenticity_token"=>"4PCqm74IA+0Q8skfQmDdsSKt1TCwZwD+P80sM15/TY0gSKCynYFuiOfoTWX3JjYVeGh1jKMIQNQBGbo7j9iUfg==", "controller"=>"trouble_tickets", "action"=>"destroy", "id"=>"12932"}
 * Timestamp  : 2021-06-04 00:50:36 UTC
 * Server : www-4.internal.bikelink.org
   * Rails root : /var/www/bikelink
 * Process: 7190

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

 * session id: [FILTERED]
 * data: {"session_id"=>"02ccfc1320e0858ded41ad466bc3e721",
  "warden.user.person.key"=>[[8017], "PsI_rt5iyywkPa--btXi"],
  "params_for_filter"=>
   {"filter_by_location"=>nil,
    "filter_by_owner"=>nil,
    "filter_by_state"=>2,
    "filter_by_priority"=>nil},
  "_csrf_token"=>"aixJabSznZ2L1d3DZwfdH8wKQiAJn6Ruqu6iqCNwoqE="}

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

 app/controllers/trouble_tickets_controller.rb:28:in `destroy'

Znovu načíst