I know this has been answered here: Javascript Include Tag Best Practice in a Rails Application, however I don't get something.
How do I specify what js file is in the :defaults tag? I tried to specify path to js instead of using tag.
In application.html.erb:
<head>
<title>...</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= yield :head %>
</head>
In view:
<% content_for :head, javascript_include_tag('qEditor/http_cdn.quilljs.com_1.3.2_quill') %>
This file is in the app/assets/javascripts/qEditor
and according to IDE the path is correct. I changed the application.js from //= require_tree .
to //= require_directory .
so the js file won't be loaded elsewhere. It doesn't work...
Could you help me to solve this? I am really new in rails. Thank you
UPDATE
application.html.erb:
<!DOCTYPE html>
<html>
<head>
<title>....</title>
<%= csrf_meta_tags %>
<%= content_for :assets do %>
<%end%>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body>
<div class="container">
<%= link_to 'Home', root_path, class: 'btn btn-default' %>
<button onclick="toggleTodos()" class="btn btn-default">Toggle TODO's</button>
<% flash.each do |key, value| %>
<div class="alert alert-<%= key %>"><%= value %></div>
<% end %>
<div class="jumbotron">
<%= yield %>
</div>
</div>
</body>
</html>