0

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.

appleII717
  • 328
  • 3
  • 12
  • One problem solve this type of issue in my case. Can u please give it a bit try? Please add this to your development.rb: config.middleware.delete Rack::Lock http://stackoverflow.com/a/18857992/751716 – Rubyrider Sep 17 '13 at 19:12

1 Answers1

0

I gave up. Know one is looking at rails4, at least yet.

I ended up using an one old suggestion and generating an included helper in the applications helper directory - versus a name-spaced directory. Not want I wanted to do, but maybe sometime later I'll figure it out. The install:helper method just replaces the helper with the include with the full code.

appleII717
  • 328
  • 3
  • 12