ruby-on-railsruby-on-rails-4titleapostrophe

Apostrophe Appearing as "'" in Title Tab of Rails App


Apostrophes are appearing as "'" in the title tabs of my Rails application. Everywhere else the apostrophes appear correctly. How may I correct this issue?

Thank you.


Solution

  • I'm not sure whether you want the apostrophe to appear as ' or as '.

    If you put your apostrophe in double quoted strings then it will render correctly:

    <title><%="example 'title'" %></title> #=> example 'title'
    

    If you put &#39; inside double quoted strings then it will be returned as it is written.

    <title><%="example &#39;title&#39;" %></title> #=> example &#39;title&#39;
    

    Finally, if you want to use &#39; and have it parsed correctly then you can use raw.

    <title><%=raw "example &#39;title&#39;" %></title> #=> example 'title'
    

    If it is not working as expected then it may be a browser issue, however, I have tested with modern versions of Firefox and Safari and it is working correctly.