简体   繁体   English

如何从Rails控制台访问引擎中的帮助程序?

[英]How do I access a helper in an engine from the Rails console?

How do I call a helper inside an engine from the Rails console? 如何从Rails控制台调用引擎内的助手? I tried 我试过了

app.coverart
app.refinery.coverart
helper.coverart
helper.refinery.coverart
Refinery::Books::Engine.helpers.coverart
Refinery::Books::Engine.app.coverart
Refinery::Books::Engine.app.helper.coverart

They all say NoMethodError: undefined method . 他们都说NoMethodError: undefined method

Rails version 3.2.14. Rails版本3.2.14。

If you want to include functions from Refinery::Books::ApplicationHelper you can do this like the following. 如果要包含Refinery::Books::ApplicationHelper函数,可以执行以下操作。

irb(main):001:0> include Refinery::Books::ApplicationHelper
irb(main):002:0> respond_to? :function_from_engine_helper
=> true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM