Actions
Bug #14689
closedActiveRecord::RecordInvalid: Validation failed: Name has already been taken
Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Foreman Integration
Target version:
-
Description
Using the salt smart proxy and salt plugin, I deleted a host from Foreman, destroyed the VM, created a new VM with the same name, and tried to use "foreman-node" to update the facts for the new host. I received the error "ActiveRecord::RecordInvalid: Validation failed: Name has already been taken" in production.log when I tried to do this.
I spoke with stbenjam on IRC and he suggested I make the following change to /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_salt-5.0.0/app/services/foreman_salt/fact_importer.rb :
def fact_names
-@fact_names ||= fact_name_class.maximum(:id, :group => 'name')
+@fact_names ||= fact_name_class.group(:name).maximum(:id)
end
This seems to have fixed the problem for me.
Actions