Search code examples
ruby-on-railsrubyruby-on-rails-4html-safe

html_safe in ruby on rails not working


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


Solution

  • 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