I’ve been using Rails engines for a while, with Blacklight and Umlaut, even before engines were well-supported in Rails3.
I’ve often had troubles with the combination of rails helpers from an engine and a local app. Or from more than one engine. Mysterious hard to understand troubles, with things interacting in mysterious ways. Here’s a stackoverflow I just found by googling, with me trying to explain one particular case I ran into trouble — it’s confusing!
The problems did seem to have to do with load order, what helper modules ended up included/applied before what other helper modules, between app and engine, seemed unpredictable and weird.
I basically gave up on defining helpers in the ordinary way, when there is expected to be any interaction between local app helpers and engine helpers (helpers in one call or override helpers in the other), and end up doing things like explicitly using the `helper` or `helper_method` in Rails controllers, which ended up ensuring that the helpers loaded that way came after helpers implicitly loaded, and thus could over-ride and refer to them.
Some Rails4 release notes make me optimistic that the problem has been identified and solved. This explains a lot, the way it worked previously was just plain wrong:
2.8 Helpers Loading Order
The order in which helpers from more than one directory are loaded has changed in Rails 4.0. Previously, they were gathered and then sorted alphabetically. After upgrading to Rails 4.0, helpers will preserve the order of loaded directories and will be sorted alphabetically only within each directory. Unless you explicitly use the
helpers_path
parameter, this change will only impact the way of loading helpers from engines. If you rely on the ordering, you should check if correct methods are available after upgrade. If you would like to change the order in which engines are loaded, you can useconfig.railties_order=
method.http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#helpers-loading-order