新手问题 rails api strip_tags and strip_links method 怎么不可以用求解释!!!

zhq_zhq · 2014年03月10日 · 最后由 zhq_zhq 回复于 2014年03月13日 · 1981 次阅读

strip_tags("Strip these tags!")
出现如下错误

strip_links 已经去除了,可以使用 gem,strip_tags 是 ActionView 内的方法,只有在 html 模版文件中才能使用,当然在其它地方使用的话 include 下 ActionView

helper.strip_tags("Strip <i>these</i> tags!")

在 controller 中使用 view_content.strip_tags
console 中需要 include ActionView::Helpers::SanitizeHelper strip_tags("Strip these tags!")

或者:3 楼说的: helper.strip_tags("Strip <i>these</i> tags!")

@kingwkb ;@leomayleomay;@huhongda谢谢!用 sanitize(HTML,tags=[])

需要 登录 后方可回复, 如果你还没有账号请 注册新账号