ac-multi-helpers-dirs

Created: 2008-11-28 20:10
Updated: 2018-08-04 17:06
License: unlicense

README.md

ac-multi-helpers-dirs

In Rails applications, helper modules are usually all located somewhere under app/helpers/. This is what is expected when eager loading helpers with helper :all. Unfortunately, it is not possible to indicate Rails other directories to find helper files in. This plugin introduces a way to circumvent this limitation.

How it works

With this plugin, helper :all will look for *_helper.rb files in every helpers directory whose path is present in the ActiveSupport::Dependencies.load_paths array.

Usage

Install the plugin:

script/plugin install <repo>

Example configuration in environment.rb:

config.load_paths += Dir["#{Rails.root}/app/*/helpers"]

This allows for having code organized like:

app/
  controllers/
    application_controller.rb
  accounting/
    models/
    views/
    controllers/
    helpers/
  system/
    models/
    views/
    controllers/
    helpers/
  ...

and have ApplicationController call the usual helper :all to eager load helpers located under both accounting/helpers/ and system/helpers/.

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more