Skip to content

Instantly share code, notes, and snippets.

@vovs03
Forked from ro31337/headers_in_views.txt
Created December 28, 2017 00:08
Show Gist options
  • Save vovs03/a8e71d747bca4b1235c772d8ee7a194c to your computer and use it in GitHub Desktop.
Save vovs03/a8e71d747bca4b1235c772d8ee7a194c to your computer and use it in GitHub Desktop.
Your views:
=== show.html.erb ===
<% content_for :header do
stylesheet_link_tag 'blabla'
end %>
<% content_for :header do
javascript_include_tag 'blabla'
end %>
<div>
... actual view goes here ...
</div>
===
Your layout (note the line 26):
=== app/views/layouts/application.html.erb ===
<!DOCTYPE html>
<html>
<head>
<title>App</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= content_for(:header) %>
</head>
<body>
<%= yield %>
</body>
</html>
===
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment