Rails引擎中的助手 [英] Helpers in Rails engine
问题描述
我正在使用Rails引擎,但是助手有问题.
I am working on a rails engine and I have a problem with the helpers.
显然,这是一个已知的问题",但目前还没有很多解决方案.问题是我有一个想全局访问的AuthenticationHelper,但是它不起作用.
Apparently this is a known "problem" but there's not a lot of solutions out there. The problem is that I have an AuthenticationHelper which I want to access globally - but it's not working.
我已阅读到可以在其中添加几行您的init.rb
,但似乎没有任何效果.
I've read that you could add a few lines to your init.rb
but it does not seem to have any effect.
您知道在引擎中使应用程序可用的最佳方法是什么吗?
Any idea what the best way to make an application available in an engine?
已修复-只需将代码(来自链接)放在engine.rb
中即可.
Fixed it- Just put the code (from the link) in the engine.rb
instead.
推荐答案
将此代码放在engine.rb中:
Put this code in engine.rb:
config.to_prepare do
ApplicationController.helper(MyEngineHelper)
end
这篇关于Rails引擎中的助手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!