contentful_rails
contentful_rails copied to clipboard
Eager load in a to_prepare block
There is an engine initializer doing this:
Rails.application.eager_load!
ContentfulModel::Base.descendents.each do |klass|
klass.send(:add_entry_mapping)
end
Rails applications cannot load application code so early. If you change a content model and reload, nobody is invoking #add_entry_mapping
on it again. In Rails 7 this is not even possible.
That should be done in a to_prepare
block, so that it runs when things are ready on boot, and also on every reload.
(This logic is not related to Zeitwerk, though Rails and Zeitwerk are being polished to uncover latent issues like this one.)