0

我正在使用Tiny Mce Editor 4.0.5. 新的.htmlRails 2

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

创建动作:

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

提交表格后,我得到

在此处输入图像描述

未定义的方法“stringify_keys!”

我试过了

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

但它不存储任何 HTML 标签,那么我如何将标签存储到我的数据库中呢?

4

2 回答 2

0

使用xss_terminate插件

在我的模型中CustomReport

xss_terminate :except => [:description]

简单易行。

于 2013-11-15T11:39:23.233 回答
0
CustomReport.create(:description => params[:custom_report][:description])

应该为您完成这项工作,但 Rails 自然会转义 html 标记,以阻止 rails 执行您需要调用的操作:

[html_safe](http://apidock.com/rails/String/html_safe)

或者

生的

在您对带有 html 标签的字符串的看法中(这是不安全的做法,在考虑这一点之前,您应该确保字符串是真正安全的,因为它可能会使您的应用程序受到攻击)

于 2013-11-06T17:45:20.027 回答