theforeman/foreman · error · Foreman::AssociationNotFound
Could not find %{association} with name: %{name}
Error message
Could not find %{association} with name: %{name} What it means
Error "Could not find %{association} with name: %{name}" thrown in theforeman/foreman.
Source
Thrown at app/models/concerns/has_many_common.rb:86
send(association).map(&:name_method)
end
end
#### belongs_to ####
def belongs_to(name, scope = nil, name_accessor: nil, **kwargs)
belongs_to_name_for(name, name_accessor)
super(name, scope, **kwargs)
end
def belongs_to_name_for(association, name_accessor)
assoc = association.to_s.tableize.singularize
assoc_name = name_accessor || "#{assoc}_name"
# SETTER _name= method
define_method "#{assoc_name}=" do |name_value|
assoc_id = assoc_klass(association).send("find_by_#{assoc_klass(association).attribute_name}", name_value).try(:id)
unless assoc_id
raise Foreman::AssociationNotFound
.new(_("Could not find %{association} with name: %{name}") % { name: name_value, association: association })
end
send("#{assoc}_id=", assoc_id)
end
# GETTER _name method
define_method assoc_name do
send(association).try(:name_method)
end
end
end
end
View on GitHub (pinned to 6b05625475)
When it happens
Trigger: Thrown at app/models/concerns/has_many_common.rb:86 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of theforeman/foreman@6b05625475 (2026-08-23).
Data as JSON: /api/errors/9aa00d35029f345d.
Report an issue: GitHub.