Ich versuche, zwei Modelle mit einer assoziativen Tabelle zwischen ihnen einzurichten. Ich habe mein Modell Assoziationen als solche definiert:ActiveRecord Association für has_one & has_many assoziative Tabelle
class Homebase < ApplicationRecord
has_many :homebase_addresses
has_many :addresses, through: :homebase_address
end
class Address < ApplicationRecord
has_one :homebase_address
has_one :homebase, through: :homebase_address
end
Und mein Verein:
class HomebaseAddress < ApplicationRecord
belongs_to :homebase
belongs_to :address
end
Meine Instanzen erstellen OK:
homebase = Homebase.create
address = Address.create
homebase_address = HomebaseAddress.create(homebase: homebase, address: address)
jedoch
homebase.addresses
das gibt Folgefehler:
ActiveRecord::HasManyThroughAssociationNotFoundError:
Could not find the association :homebase_address in model Homebase
Was fehlt mir hier? Tausend Dank!
Dank, dass es fest! –