Bug #8405
closedResolve Templates button on Host#edit broken for multi-nic systems
Description
If a host has extra interfaces, then the Resolve Templates button is broken for existing hosts, because the DB tries to match Nics with IDs to a Host without. THis is because we call Host.new(params[:host]) which creates a new Host with id=nil, but uses the nested attrs for the nics. This leads to logs like this:
Nic::Base Load (0.2ms) SELECT "nics".* FROM "nics" WHERE "nics"."host_id" IS NULL AND "nics"."id" IN (17, 19) ORDER BY identifier
not found: Couldn't find Nic::Base with ID=17 for Host::Managed with ID=
To reproduce, create a host with at least one nic in the Network tab (i.e not just the primary interface). Save it (as it works fine while both entities have id=nil), then edit and try the Resolve Templates button. It should say "Sorry but no templates were configured."
To fix, we should probably a) drop the nested attrs for the application.js#template_info JS function, and b) drop them again in the controller (in case someone hits it from outside the UI).