Reputation: 525
I've been trying to use cdata_section, content_tag, escape_once and tag from the tag helper on rails to make the "X" appear from ✖
<%= link_to( ("✖"), url_options = {:base_rate_id => rates.id}, class: "button tiny" ) %
no luck with the different methods. it either displays nil or the raw literal "✖"; is there better way?
Upvotes: 0
Views: 162
Reputation: 5015
You can use the following syntax
<%= link_to("✖".html_safe, url_options = {:base_rate_id => rates.id}, class: "button tiny") %>
However you should be careful using html_safe
. Ensure that no user provided input makes its way into a string rendered using it.
Upvotes: 1
Reputation: 12320
Use ActionView::Helpers::SanitizeHelper
<%= link_to( sanitize("✖"), url_options = {:base_rate_id => rates.id}, class: "button tiny" ) %>
Upvotes: 1
Reputation: 9747
You just need to un-escape HTML entities as follow:
<%= link_to(CGI.unescapeHTML("✖"), url_options = {:base_rate_id => rates.id}, class: "button tiny" ) %>
P.S.: May be you need to include the CGI library:
require 'cgi'
Upvotes: 1