0

In my rails mountable engine:

config.to_prepare do
  # works fine, and reload automatically in development
  ApplicationController.helper :application

  # works fine, but doesn't reload. After restart server, it works.
  ApplicationController.helper Rails.application.helpers

It looks like fine when arg is symbol or string. But it doesn't work when arg is a module like Rails.application.helpers.

Or is there a good way to get all helpers like [:application, :users] from Rails.application.helpers.

Rails: 4.2.3

2 Answers 2

0

You can configure autoload_paths of the engine.

lib/my_engine/engine.rb

module MyEngine
  class Engine < ::Rails::Engine
    ...
    config.autoload_paths += Dir[Engine.root.join('app', 'helpers')]
  end
end

http://api.rubyonrails.org/classes/Rails/Engine.html

1
  • 1
    I have already tried autoload_paths, but it doesn't work. And I want to reload main app helpers.
    – akm
    Commented Aug 5, 2015 at 9:56
-1

for people using rails 6, you might want to try using the classic autoloader instead of zeitwerk

config.autoloader = :classic

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.