A
A
Anton Misyagin2015-08-29 10:51:14
Ruby on Rails
Anton Misyagin, 2015-08-29 10:51:14

The js code is included 2 times in application.js and in its file (?

app
..assets
....javascripts
......application.js
......somecode.js
app/assets/javascripts/application.js /app/views/layouts/application.html.haml in output in public/assets I expect application.js, but I get application.js and somecode.js. And in the page code I see:
//=require somecode

= javascript_include_tag 'application'

<script src="/assets/somecode-3b9fe45f9d9a8007fa4c213cfbced5fd.js?body=1"></script>
<script src="/assets/application-3b9fe45f9d9a8007fa4c213cfbced5fd.js?body=1"></script>

Those. code connected 2 times. This unexpected behavior is annoying.
The task is this: in the javascripts folder of raw assets, collect all the necessary scripts. Include them in one application.js and collect them into one file as the output of resource compilation.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
TyzhSysAdmin, 2015-08-29
@sunnmas

In addition to vsuhachev , replace
/config/environments/development.rb with If you want to have what you want in the development environment :) PS not necessarily if the file is located in and there is a line in application.js
//=require somecode/app/assets//= require_tree .

V
vsuhachev, 2015-08-29
@vsuhachev

firstly, it matters what environment you are in, in development this behavior is normal, and assets for production are collected using the assets:precompile task;
secondly, by default, the manifest (application.js) usually has a require_tree command that includes all files from subdirectories, those. require somecode is not needed,
read here how it all works

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question