Hello Foreman community,
I’m developing a plugin for Foreman that ought to add fields for keeping BGP configuration settings per Subnet in the database. I dislike the idea of changing the subnets table, so I want to keep the new attributes in a separate table.
module SubnetBGPConfig < ActiveRecord::Base
belongs_to :subnet, inverse_of: :subnet_bgp_config
end
module SubnetExtensions
extend ActiveSupport::Concern
included do
has_one :subnet_bgp_config, inverse_of :subnet
accepts_nested_attributes_for :subnet_bgp_config
end
end
Now, whenever the Subnet form is rendered, an error occurs:
Association named ‘subnet_bgp_config’ was not found on Subnet::Ipv4; perhaps you misspelled it?
As far as I understand Rails’ single Table Inheritance (STI) this should work just fine, since…
This means that all behavior added to Vehicle is available for Car too, as associations, public methods, etc.
Can you tell what my problem is and/or how to solve it with Foreman (v3.5.1)?
I have tried to attr_exportable :subnet_bgp_config
as well as the nested attributes, both failed.
Another option I thought of was…
module SubnetIPv4Extensions
extend ActiveSupport::Concern
included
has_one :subnet_bgp_config, through: :subnet
end
end
But that failed, because the IPv4 and IPv6 subclasses don’t have an association to Subnets, which makes sense on face value.
Including SubnetExtensions
into the subclasses so far isn’t working out either.
I’d be grateful for any hints or tips you can spare. Thank you for your time,
Xavier.