Answer the question
In order to leave comments, you need to log in
How to include certain files?
Rails has an assets folder. there lies scripts and styles. For each new controller, a new coffescript and a new scss are created.
Is it possible to make sure that if we use a specific controller, then application.js and the script of this particular controller are loaded?
And then I get a lot of files already and they are loaded on all pages. And I need to load certain scripts and application.js in certain pages, how can I implement this?
Answer the question
In order to leave comments, you need to log in
You can do this
in the layout, write
A on the connect page:
<% content_for :after_js do %>
<%= javascript_include_tag 'pages/users/index' %>
<% end %>
Rails.application.config.assets.precompile += ['pages/users/index.js']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question