Skip to content

Instantly share code, notes, and snippets.

@aakashd
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aakashd/82c4e7ff51cfa60ebd04 to your computer and use it in GitHub Desktop.
Save aakashd/82c4e7ff51cfa60ebd04 to your computer and use it in GitHub Desktop.
how to include page specific javascript code after application.js
<div class='content'>
<!-- your application code, which requires some JS -->
</div>
<% content_for :javascript do %>
<script type="text/javascript">
$(function () {
$('th').tooltip();
});
</script>
<% end %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9">
<title><%= application_title %></title>
<%= render :partial => 'layouts/header_meta_content' %>
<%= stylesheet_link_tag 'application', media: 'all' %>
<meta charset="UTF-8">
<%= csrf_meta_tags %>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--[if lte IE 9]>
<%= javascript_include_tag 'modernizr' %>
<![endif]-->
</head>
<body class="background-light">
<div class="container">
<div class="content">
<%= render :partial => 'layouts/nav_bar' %>
<%= render :partial => 'application/alert' %>
<%= yield %>
</div>
</div>
<%= javascript_include_tag 'application' %>
<%= yield :javascript %>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment