Search code examples
ruby-on-railsdomhyperlinkruby-on-rails-5head

Rails: How to put stuff in header


In my Rails App I included OneSignal which requires the following link to be placed in the head of the document:

<link href='/manifest.json' rel='manifest'>

Unfortunately with Rails I cannot put this link there, because the entire layout gets rendered inside the body.

While this ...

$(document).ready(function(){
    $("head").append("<link href='/manifest.json' rel='manifest'>");
});

seems to work in development mode, it does not work in production.

How can I add this link to my head section of the document?


Solution

  • You can add <link href='/manifest.json' rel='manifest'> in app/views/layouts/application.html.erb.