Delete Host action should return /hosts instead of 404 on /hosts/delete-host.domain
When I use the big red "Delete" button to remove a VM that was created, it is successful, but it tried to return to the same page (/hosts/delete-me.domain.com) instead of just going back to /hosts. This causes a "host not found" (404) error.
#4 Updated by Tommy McNeely over 6 years ago
I am using 1.7.0, and if it matters, my VM is in the "Digital Ocean" Compute Resource...
- Hosts -> All Hosts
- Click a Host to bring up the "host show" details
- on the hosts screen I am generally clicking around (tabs on the left), but I doubt that matters
- Click the Delete button at the top
- Get a "Host Not Found" page (url is /hosts/system-i-deleted.domain.com)
#8 Updated by Tommy McNeely over 6 years ago
Not sure if this will work...
#9 Updated by Dominic Cleal over 6 years ago
That worked, thanks. We also just had Dw_Sn on IRC with the same problem, so investigated it a bit further.
I think what's happening is due to #5773, as when you click the link to destroy, the show page is sent as the referrer. https://github.com/theforeman/foreman/blob/1.7.0/app/controllers/concerns/foreman/controller/auto_complete_search.rb#L6 runs on a destroy action (it isn't excluded), so the show page gets stored as the page to redirect back to.
This is probably an issue only with hosts as I don't think other show pages have delete buttons, it's usually on the index. If we simply exclude the destroy action too, then it means if you delete a host from the index that #5773 won't work as the referrer won't be stored.