seyhunak / twitter-bootstrap-rails

Twitter Bootstrap for Rails 6.0, Rails 5 - Rails 4.x Asset Pipeline
https://github.com/seyhunak/twitter-bootstrap-rails
4.5k stars 1k forks source link

Revise loading helpers during initialization #943

Closed fxn closed 1 year ago

fxn commented 2 years ago

The way this engine loads helpers has a couple of things that can be polished.

On one hand, when referring to a framework component, it is better to wrap your code in an ActiveSupport.on_load hook, because that is the public contract to say: This component is ready.

Then, the to_prepare callbacks are not necessary. You wrap your code in to_prepare blocks in order to use reloaded stuff again. However, in this case nothing is reloaded, because framework classes and modules like ActionController::Base aren't.

Since I was on it, the patch suggests to remove the require_relative calls. Just autoload, but put the helpers in the autoload_once_paths to tell Rails this code is not reloadable. You can autoload during boot from these paths even in Rails 7.

If client code had leftover require calls in place to workaround #936, that is still compatible.