1

I'm using ruby 2.0.0 This is my controller..

@mail_msg = @store_items.where(id: params[:button_id]).first.email_confirmation_text
p "-------------------------"
p @mail msg
p @mail_msg.html_safe

This is my console(terminal) output

"-------------------------"
"<p>You have purchased Spice It Up. Points have been redeemed from your main account.</p>"
"<p>You have purchased Spice It Up. Points have been redeemed from your main account.</p>"

And what im getting in my console is the same. I cant escape the html tags.

Update

I have this value in my view.. in my view page

<%= @mail_msg.html_safe %>

Still its not working..

Please help

Nidhin S G
  • 1,685
  • 2
  • 15
  • 45

2 Answers2

6

Try these one may will help you

strip_tags("Strip <i>these</i> tags!")

# => Strip these tags!

strip_tags("<b>Bold</b> no more!  <a href='more.html'>See more here</a>...")

# => Bold no more! See more here...

strip_tags("<div id='top-bar'>Welcome to my website!</div>")

# => Welcome to my website!enter code here

Bharat soni
  • 2,686
  • 18
  • 27
2

html_safe and raw work in views, use

<%= raw @mail_msg %> 

or

<%= @mail_msg.html_safe %>
Rajdeep Singh
  • 17,621
  • 6
  • 53
  • 78