Search code examples
ruby-on-railsfacebook-sharehtml-safe

how to use html_safe in meta tag og:description content in ruby on rails


I use og:description meta tag like this

<meta property="og:description" content="<%= @post.description.html_safe %>" />

But it shows description of post in top of the page.


Solution

  • I have ever got this error in my php code to show og file. I thought, It will work to in rails. You just change "" into ''

    <meta property="og:description" content='<%= @post.description.html_safe %>'/>
    

    or

    <meta property="og:description" content='<%= @post.description %>'/>
    

    I hope this help you.