如何将HTML标记存储到DB中 [英] How to store HTML tags into DB

查看:195
本文介绍了如何将HTML标记存储到DB中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Rails 2 中使用 Tiny Mce Editor 4.0.5 >
new.html

 <%form_for @custom,:url => ;createdo | c | - %> 
<%= c.text_area'description'%>
<%= c.submit%>
<%end%>

创建操作:


$ b b

  CustomReport.create(params [:custom_report] [:description])


b $ b

提交表单后,我收到





未定义的方法`stringify_keys!'



>

  CustomReport.create(:description => params [:custom_report] [:description])

但是它不存储任何HTML标签,所以我如何将标签存储到我的数据库?

解决方案

使用 xss_terminate 插件



在我的模型中 CustomReport


xss_terminate:except => [:description]



I'm using Tiny Mce Editor 4.0.5 in Rails 2.

new.html

<% form_for @custom, :url=>"create" do |c| -%>
  <%= c.text_area 'description' %>
  <%= c.submit %>
<% end %>

Create Action:

CustomReport.create(params[:custom_report][:description])

After submission of form I get

undefined method `stringify_keys!'

Along that I tried

CustomReport.create(:description => params[:custom_report][:description])

But it doesn't store any HTML tags, so how I can store tags along to my DB?

解决方案

Using xss_terminate plugin

And in my model CustomReport

xss_terminate :except => [:description]

easy and simple.

这篇关于如何将HTML标记存储到DB中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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