I upgraded an engine to Rails 4 and I'm having problems trying to configure an optional shared helper. The helper Assessable::DisplayHelper
has two methods that just render html.
What I mean by optional is
- The default config desired is that the helper should made available to the main.app for use outside the engine, but details are hidden. (the html is generated from a hash generated by the engine but used by the main app)
- An optional generator installs the helper in helpers/assessable/display_helper which the app user can modify if they wish.
The optional generator works fine, over-riding the helper in the engine, but I can't figure out a way to make the default mode to work.
I've read the note about helper load order in the rails 4 release notes, but not sure what I need to change. About everything I've tried
- Adding
helper Assessable::DisplayHelper
to application controller (not preferred) - Trying to include
Assessable::DisplayHelper
in a stubbed helper. - A few other stabs in the dark
Produces and error:
RuntimeError: Circular dependency detected while autoloading constant Assessable::DisplayHelper
...
from /Users/me/.rvm/gems/ruby-2.0.0-p247@rails4/gems/actionpack-4.0.0/lib/action_controller/railties/helpers.rb:17:in `inherited'
from /Users/me/work/pm/app/controllers/application_controller.rb:1:in `<top (required)>'
I gone back and forth between having the Display functions in a class and in a helper. I switched back to the helper because I had trouble getting the class installed in the main app. The goal is the have `{class.}display_xxx(hash,post) work with either the default or optional config.
Any suggestions on either approach would be helpful.