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 3783426
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:13:23+00:00 2026-05-19T11:13:23+00:00

My question relates to this one , but I am trying to reverse the

  • 0

My question relates to this one, but I am trying to reverse the default Rails 3 behavior of “<%=” so that I can inject HTML.

In my scenario, I have an old Rails 2 plug that generates HTML. My view will then need to inject this HTML in the page.

When this plugin creates HTML like this stored in a variable html_to_show:

<p class="notice"><span></span>Sorry about this, but we have a problem...</p><p class="error"><span></span>Cannot go to next step</p>

and in the view I try to show the contents of html_to_show like this:

<%= html_to_show %>

… what I get in my browser is this:

&lt;p class="notice"&gt;&lt;span&gt;&lt;/span&gt;Sorry about this, but we have a problem...&lt;/p&gt;&lt;p class="error"&gt;&lt;span&gt;&lt;/span&gt;Cannot go to next step&lt;/p&gt;

How can I get Rails 3 to inject the contents of html_to_show exactly as it is, without any sanitization?

  • 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-19T11:13:24+00:00Added an answer on May 19, 2026 at 11:13 am

    Short answer:

    <%= html_to_show.html_safe %>
    

    Long answer:

    Rails escapes all html to protect from XSS attacks. Adding .html_safe prevents the escaping.

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

Sidebar

Related Questions

[This question is related to but not the same as this one .] My
[This question is related to but not the same as this one .] If
This is related to my previous question , but a different one. I have
Another question related to this one . I have a List<SortableObjects> that is the
I have a question related to this one : I'm trying to attach an
This is a related question to one I posted earlier... I'm trying to sum
This is a question related to another one I asked that was specific to
This is related question to my previous question but different one. After searching a
I believe this question is related to this one also, since I'm trying to
I have a question related to this one . I don't want to do

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.