Sunday, May 19, 2024
47
rated 0 times [  51] [ 4]  / answers: 1 / hits: 18770  / 12 Years ago, sun, july 1, 2012, 12:00:00

In my application.js file, I have:



//= require jquery
//= require jquery_ujs
//= require underscore
//= require backbone
//= require_tree .
//
//= require .//community_app
//
//= require_tree ../templates/
//= require_tree .//models
//= require_tree .//collections
//= require_tree .//views
//= require_tree .//routers


but the generated html doesn't obey this order:



<head>
<title>CommunityApp</title>
<link href=/assets/application.css?body=1 media=all rel=stylesheet type=text/css />
<link href=/assets/communities.css?body=1 media=all rel=stylesheet type=text/css />
<link href=/assets/home.css?body=1 media=all rel=stylesheet type=text/css />
<script src=/assets/jquery.js?body=1 type=text/javascript></script>
<script src=/assets/jquery_ujs.js?body=1 type=text/javascript></script>
<script src=/assets/underscore.js?body=1 type=text/javascript></script>
<script src=/assets/backbone.js?body=1 type=text/javascript></script>
<script src=/assets/collections/communities.js?body=1 type=text/javascript></script>
<script src=/assets/community_app.js?body=1 type=text/javascript></script>
<script src=/assets/home.js?body=1 type=text/javascript></script>
<script src=/assets/models/community.js?body=1 type=text/javascript></script>
<script src=/assets/application.js?body=1 type=text/javascript></script>
<meta content=authenticity_token name=csrf-param />
<meta content=ktrLMDYSJaU/mmgmzfpxDfMin7OCXga4K5gVIJZHJUI= name=csrf-token />
</head>
<body>


Collections is loaded before the model which gives me error on the front-end. How can I make it so it loads in a specific manner the js files?
thanks


More From » ruby-on-rails

 Answers
9

You've still got a



//= require_tree .


Higher up, which is loading everything, apparently in alphabetical order. Remove that (obviously making sure that everything is required elsewhere) and you should be fine. You might be able to make that the last line of your application.js but I don't remember the specified behaviour when two statements end up requiring the same file


[#84537] Friday, June 29, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
deonkalvinw

Total Points: 409
Total Questions: 96
Total Answers: 89

Location: Saint Pierre and Miquelon
Member since Sun, Nov 27, 2022
2 Years ago
deonkalvinw questions
Sun, Feb 6, 22, 00:00, 2 Years ago
Tue, Dec 28, 21, 00:00, 2 Years ago
Sun, Aug 22, 21, 00:00, 3 Years ago
Sun, Mar 7, 21, 00:00, 3 Years ago
;