Rails控制台-使用image_tag方法 [英] Rails console - use image_tag method

查看:195
本文介绍了Rails控制台-使用image_tag方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Rails控制台中执行image_tag方法

How can I execute a image_tag method in a Rails console

  1. 运行控制台 $ rails c

  1. Run the console $ rails c

加载助手

包括ActionView :: Helpers

include ActionView::Helpers

  • 执行命令

  • Execute the command

    image_tag('test.png')

    image_tag('test.png')

  • 我遇到一个奇怪的错误.

    I got a strange error.

    请帮助!

    推荐答案

    确定...我找到了解决方案.该错误仅在Rails 3中显示,但我通过设置

    OK... I found the solution. The error is showing only in Rails 3 but I fixed it by setting the

      config.action_controller.asset_host = "http://..."
      config.action_mailer.asset_host = "http://..."
    

    在我的环境文件中(例如development.rb). 真是难以置信!

    in my environemnt file (e.g. development.rb). Unbelievable!

    此功能现在是插件 https://github.com/xpepermint/js_erb 的一部分.

    This functionality is now part of a plugin https://github.com/xpepermint/js_erb.

    这篇关于Rails控制台-使用image_tag方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆