twitter-bootstrap-rails icon indicating copy to clipboard operation
twitter-bootstrap-rails copied to clipboard

Revise loading helpers during initialization

Open fxn opened this issue 2 years ago • 0 comments

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.

fxn avatar Nov 12 '21 11:11 fxn