开发者

html.erb doesn't recognize html tags?

New to RoR, so please don't kill me ;)

Was wondering why does not Rails 3 recognize HTML tags retrieved from dat开发者_开发知识库abase?

For example,

         Name   Content                     
         Title  <b>Great</b>    Show    Edit    Destroy

I wanted to have Content to be bold and put < b > tag around it, when it retrieves from a database it looks like a plain English.

Any thoughts?

Thank you in advance.


If I got this right, you need to do this:

<%= myrecord.content.html_safe %>

to get "real" html and not just escaped html code.


Even though it is unsafe to deliberately output HTML from the DB, you should call raw on the content you're trying to print.

<%= raw @object.my_content %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜