You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ActionView::Base shouldn't be loaded during the initialization process.
Rails does a poor job of making this explicit, IMO - there's a suggestion that you shouldn't load frameworks (ActiveRecord::Base, ActionView::Base etc) during boot here: https://edgeguides.rubyonrails.org/engines.html#load-and-configuration-hooks, since it slows the boot process.
More concretely, loading those frameworks too soon can mean that they ignore configuration - eg setting config.active_record.belongs_to_required_by_default in config/initializers/new_framework_defaults.rb is ignored if ActiveRecord::Base has already been loaded.
As it happens, ActionView::Base doesn't have the same problem because most of its settings are propagated to, eg, ActionView::Helpers::TagHelper in after_initialize, rather than being set directly on ActionView:Base, but that seems a fragile thing to rely on.
Actual behavior
ActionView::Base loads as soon as view_component is required, here:
Steps to reproduce
Add ViewComponent >= 2.66 to Gemfile, boot rails (eg
rails console
).Expected behavior
ActionView::Base shouldn't be loaded during the initialization process.
Rails does a poor job of making this explicit, IMO - there's a suggestion that you shouldn't load frameworks (ActiveRecord::Base, ActionView::Base etc) during boot here: https://edgeguides.rubyonrails.org/engines.html#load-and-configuration-hooks, since it slows the boot process.
More concretely, loading those frameworks too soon can mean that they ignore configuration - eg setting
config.active_record.belongs_to_required_by_default
in config/initializers/new_framework_defaults.rb is ignored if ActiveRecord::Base has already been loaded.As it happens, ActionView::Base doesn't have the same problem because most of its settings are propagated to, eg, ActionView::Helpers::TagHelper in after_initialize, rather than being set directly on ActionView:Base, but that seems a fragile thing to rely on.
Actual behavior
ActionView::Base loads as soon as view_component is required, here:
System configuration
Rails version: 7.0.3
Ruby version: 3.1.2
Gem version: 2.6.9
The text was updated successfully, but these errors were encountered: