Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6027135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:32:49+00:00 2026-05-23T04:32:49+00:00

I have some simple erb code in one of my views in a rails

  • 0

I have some simple erb code in one of my views in a rails project.

<%= comment.body %>

I’d like the html tags in the comment.body to be preserved as they have formatting information. I’ve verified that the text is saved in the database properly like

<b>hello</b>

However it turns out on the page to be <b>hello</b> not hello as I expect.

How could this be? I’m not using <%= h to escape the html code.

How do I make it not escaping? I’m using rails 3. Does this matter?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:32:50+00:00Added an answer on May 23, 2026 at 4:32 am

    Rails 3 now automatically escapes your output.

    To unescape the text and use the actual tags, use raw(...):

    <%= raw(comment.body) %>
    

    However, be careful with this, as it will allow any tags, including scripts (potentially malicious). A safer option might be to have users use markdown-formatted text or something similar, rather than allowing raw HTML tags.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple search form that looks something like: app/views/search/index.html.erb <%= form_for @search,
Let's say I have some simple Javascript like: <script> var hello = function(){ alert(Hello
I have some VERY simple code to return the title for a section header:
I have a view in this directory: app/views/mobile/dis/my_view.html.haml and in it I have simple
Gists of controller code at bottom of page I have a simple rails nesting
I have some simple jQuery that renders a page in my Rails app. Here's
I have this Rails app that serves an index.html.erb by a UsersController. In the
I have some simple constraints involving multiplication of reals in z3 that are producing
I have some simple JQuery / Javascript to perform some simple logic for all
I have some simple markup: <table> <tr> <td>Menu Item</td> </tr> </table> <div> <table> <tr>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.