How to store HTML tags into DB

前端 未结 2 497
小蘑菇
小蘑菇 2020-12-22 05:19

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

new.html

<% form_for @custom, :url=>\"create\" do |c|         


        
相关标签:
2条回答
  • 2020-12-22 05:52

    Using xss_terminate plugin

    And in my model CustomReport

    xss_terminate :except => [:description]

    easy and simple.

    0 讨论(0)
  • 2020-12-22 06:02
    CustomReport.create(:description => params[:custom_report][:description])
    

    should do the job for you, but Rails would naturally escape html tags, to stop rails from doing that you would need to call:

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

    or

    raw

    in your view on the string with the html tags (This is not safe practice, you should be sure the string is sincerely safe before considering this, as it can expose your app to attacks)

    0 讨论(0)
提交回复
热议问题