How to stop automatic coding of <% = lines%> using Rails 3

I use rails 3. In my index.html.erb and in my index.js.erb, if I have:

 <%= "string with unsafe characters' like <" %> 

It will be automatically encoded:

 string with unsafe characters&quot; like &amp; 

just as if I used:

 <%=h "string with unsafe characters' like <" %> 

How can I stop him? I saved a few short bits of JavaScript that I need to insert into the template without automatically encoding the string?

+4
source share
1 answer

Just use the raw method as follows:

 <%=raw "string with unsafe characters' like <" %> 
+10
source

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


All Articles