Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Special characters in link_to

I would like to have a multiple sign '×' inside a link_to helper in my Rails 3 app.

Straightforward code <%= link_to '&times;', model, :confirm => 'Sure?', :method => :delete %> outputs &times;on my page. How to fix it?

like image 243
Nikita Barsukov Avatar asked Apr 03 '11 15:04

Nikita Barsukov


1 Answers

To prevent your string from being "made safe" by Rails' output buffer:

<%= link_to '&times;'.html_safe, model, :confirm => 'Sure?', :method => :delete %>

Footnote

In my own pages, I encode everything as UTF-8, which means that I can use the real Unicode characters directly, rather than use the &...; code, but this probably isn't an option for you if you didn't start your project with that intent.

like image 60
Scott Avatar answered Sep 29 '22 13:09

Scott