Rails helpers return only strings. How do I return HTML?

I am trying to return this in a predictable HTML way:

'Page Total ' + @total_on_page + tag('br') + 'Total All Pages'.html_safe + @total 

But instead, it just parses br/ like plain text. How to return working version of HTML br/ ?

Expected Result:

 Page Total $123123 Total All Pages $12312312 

Actual output:

 Page Total $8,296.42<br />Total All Pages$23,669.73 
+4
source share
1 answer

. At the end of .html_safe, only the last line is applied, not the general line. You need something more:

 ('Page Total ' + @total_on_page + tag('br') + 'Total All Pages' + @total).html_safe 
+10
source

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


All Articles