Rails - output content, disinfection or <% = h?

I recently made a small rails3 application to convert old cms written in another language. After migrating the content, I am having problems releasing the content from the database.

The @ content.desc field sometimes has html. Currently, the only way to make it work is:

<%= sanitize content.desc %>

But is this the best way? When I use <%=h @content.desc %>, I can see html tags. When I use <%= simple_format @content.desc %>, I get an unholy interval.

Is there a definitive guide somewhere where I can see all the options when releasing content? I tried to search, but I can not do anything (rails newb, I know).

+3
source share
3

, "", HTML Rails 3. , sanitize, h, link_to , , . . .

, HTML-, @content.desc, , : <%= @content.desc.html_safe %>.

+5

Rails 3 HTML, . , , , ,

<%= @content.desc.html_safe! %>

+2

Source: https://habr.com/ru/post/1785318/


All Articles