I have <%= f.label :cost, “Cost (£/m)” %> in a file
_form.html.erb. When the form is rendered instead of getting “” I
just get “£” being rendered. I am using utf-8 encoding. Why is
this happening?
On Nov 10, 12:54pm, Bill M. [email protected] wrote:
I have <%= f.label :cost, “Cost (£/m)” %> in a file
_form.html.erb. When the form is rendered instead of getting “” I
just get “£” being rendered. I am using utf-8 encoding. Why is
this happening?
If you’re on a version of rails that has the automatic xss stuff
enabled you should call html_safe on that string, or rails will pass
it through h for you
Fred
Bill M. wrote in post #960534:
I have <%= f.label :cost, “Cost (£/m)” %> in a file
_form.html.erb. When the form is rendered instead of getting “” I
just get “£” being rendered. I am using utf-8 encoding. Why is
this happening?
Are you using Rails 3, by any chance? If so, then strings get
HTML-escaped by default. Either use the literal £ character (probably
the best choice) or mark the string as raw.
In general, except for <, >, &, and maybe , there’s
little reason to use &entities in HTML files these days.
Best,
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
Thanks very much.