我有一个客户希望他们的元描述包含注册符号,但它给我一个无效的字符错误,并使用® 在说明中不转换为®。 使用ree-1.8.7和rails 3.1.1
一些附加信息,此页面描述作为@page_description保存在控制器中,然后以部分方式引入页面。 错误似乎发生在控制器中,因此我猜测必须有一种使用®符号的红宝石方式。
I've got a client who wants their meta descriptions to include the register symbol, but it gives me an invalid character error, and using ® doesn't translate to a ® in the description. Using ree-1.8.7 and rails 3.1.1
Some additional information, this page description is saved in a controller as @page_description and then brought in on the page in a partial. The error seems to be occurring in the controller, so I'm guessing there must be a ruby way of using the ® symbol.
最满意答案
使用html_safe方法将字符串呈现为html。
试试@page_description.html_safe
编辑1:
® 是html中®的字符实体引用。
默认情况下,Rails不会将字符串呈现为html。
为了覆盖此行为,您需要使用html_safe将字符串呈现为html。
Use html_safe method to render the string as html.
try @page_description.html_safe
Edit 1:
® is the character entity reference for ® in html.
Rails does not render string as html by default.
In order to override this behaviour, you need to use html_safe to render the string as html.
更多推荐
使用,error,方式,电脑培训,计算机培训,IT培训"/> <meta name="description"
发布评论