Rails 一段 html 代码存储到数据库然后在取出来在页面显示

wangping · February 12, 2014 · 2283 hits

一段 html 代码存储到数据库然后在取出来在页面显示,如果我点击了更新按钮,然后跳到原页面,用 raw(html 的 string),生成的页面所有的 onclick 属性的值都为空了,然后刷新页面才会有。 而如果不用 raw 的话,直接在页面显示 html 的源代码,onclick 的值是有的。比如: 保存前: 保存后:

刷新后:

源代码:

<%=raw @chi.hash_content.html_safe%>
No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.