【发布时间】:2011-05-05 07:05:46
【问题描述】:
如何在 Rails 控制台中执行 image_tag 方法
运行控制台 $ 导轨 c
-
加载助手
包括 ActionView::Helpers
-
执行命令
image_tag('test.png')
我遇到了一个奇怪的错误。
请帮忙!
【问题讨论】:
标签: ruby-on-rails helper irb actionview actionviewhelper
如何在 Rails 控制台中执行 image_tag 方法
运行控制台 $ 导轨 c
加载助手
包括 ActionView::Helpers
执行命令
image_tag('test.png')
我遇到了一个奇怪的错误。
请帮忙!
【问题讨论】:
标签: ruby-on-rails helper irb actionview actionviewhelper
不确定您为什么会收到该错误。很奇怪。
但是 Rails 控制台通过 helper 变量公开了 helper 方法。所以这应该有效:
helper.image_tag('test.png')
【讨论】:
好的...我找到了解决方案。该错误仅在 Rails 3 中显示,但我通过设置
config.action_controller.asset_host = "http://..."
config.action_mailer.asset_host = "http://..."
在我的环境文件中(例如 development.rb)。 难以置信!
此功能现在是插件https://github.com/xpepermint/js_erb 的一部分。
【讨论】: