加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 在rails控制台中使用html_escape等辅助方法

发布时间:2020-12-16 19:24:14 所属栏目:百科 来源:网络整理
导读:我试图在我的视图中看到我的变量编码出了什么问题.所以我启动了rails控制台并试着这样做 $rails consoleLoading development environment (Rails 3.2.11)irb(main):001:0 html_escape({:a=1,:b="my str"})NoMethodError: undefined method `html_escape' for
我试图在我的视图中看到我的变量编码出了什么问题.所以我启动了rails控制台并试着这样做
$rails console
Loading development environment (Rails 3.2.11)
irb(main):001:0> html_escape({:a=>1,:b=>"my str"})
NoMethodError: undefined method `html_escape' for main:Object

如何在rails控制台中使用h或html_escape?

解决方法

你通过帮手来称呼它.有些方法是私有的,所以你可能需要使用send来调用它们
helper.send(:html_escape,'123')
helper.pluralize 3,'user'

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读