diff --git a/app/helpers/discovered_hosts_helper.rb b/app/helpers/discovered_hosts_helper.rb index 74db45d2..f262e80b 100644 --- a/app/helpers/discovered_hosts_helper.rb +++ b/app/helpers/discovered_hosts_helper.rb @@ -94,7 +94,14 @@ def provision_button(host, authorization_options) end def host_path(host) - return super unless controller_name == 'discovered_hosts' + return discovered_host_path(host) if controller_name == 'discovered_hosts' + + # This is a hack to fix the hostgroup selection on the discovered host edit page + # The hostgroup onChange action is replacing the form url from `/discovered_hosts/:id` + # to `/hosts/:id``, which is not correct (in this case) and it breaks the form submission + return super unless controller_name == 'hosts' && action_name == 'process_hostgroup' + return super unless Host::Discovered.find_by(id: host[:id]) + discovered_host_path(host) end