comfy / active_link_to

Rails view helper to manage "active" state of a link
MIT License
844 stars 84 forks source link

Use ActionView::Base's on_load hook for monkey-patching #52

Closed amatsuda closed 7 years ago

amatsuda commented 7 years ago

Currently, when this gems was bundled to an app, bundler requires lib/active_link_to/active_link_to.rb, then it immediately loads ActionView::Base at the bottom of the file. Hence, the application always loads the whole Action View library and all of its related gems even when not actually using any of view components (e.g. running rails r, running test/models/*, etc.)

The attached patch improves this situation by using Action View's handy hook for monkey-patchers, which enables us to postpone the monkey-patch loading until someone actually requires AV/base.

GBH commented 7 years ago

Interesting. Learned something today. Thanks!