我发现了一些文章解决了引擎内的助手问题,这些问题不适用于消费(父)应用程序.为了确保我们都在同一页上,让我们说我们有这个:
module MyEngine
module ImportantHelper
def some_important_helper
...do something important...
end
end
end
Run Code Online (Sandbox Code Playgroud)
如果您查看"隔离引擎的助手"(L293)中的rails引擎文档,它会说:
# Sometimes you may want to isolate engine, but use helpers that are defined for it.
# If you want to share just a few specific helpers you can add them to application's
# helpers in ApplicationController:
#
# class ApplicationController < ActionController::Base
# helper MyEngine::SharedEngineHelper
# end
#
# If you want to include all of the engine's helpers, you can use #helpers …Run Code Online (Sandbox Code Playgroud) ruby-on-rails view-helpers helpers rails-engines ruby-on-rails-3.1