Rails 3.1 asset pipeline and manually ordered Javascript requires?

You can require each file in particular order and then add: require_self instead of: require_tree.

You can require each file in particular order and then add: //= require_self instead of: //= require_tree .

You have two possible structure : the first one and the second one. With both following examples, you expose a package at /assets/externals.js. You can javascript_include_tag this package, but you can also require it in your application.

Js file. The first one vendor/ ├── assets │ ├── javascripts │ │ ├── externals. Js │ │ ├── modernizr-1.7.Js │ │ └── underscore-1.1.6.

Js │ └── stylesheets └── plugins The file externals. Js contains : //= require . /underscore-1.1.6.

Js //= require . /modernizr-1.7.Js The second one vendor/ ├── assets │ ├── javascripts │ │ └── externals │ │ ├── index. Js │ │ ├── modernizr-1.7. Js │ │ └── underscore-1.1.6.

Js │ └── stylesheets └── plugins The file index. Js contains : //= require . /underscore-1.1.6.

Js //= require . /modernizr-1.7.js.

One thing to add, it was confusing for me; once the externals is setup you can reference it in application. Js with a simple //= require externals or via javascript_include_tag('externals') in a view/layout – house9 May 27 at 15:04 Erf, I was just adding this information in my post, but good point anyway. Better to see that twice than zero.

:D – Romain Tribes May 27 at 15:08 I tried this, but when I go to /assets/externals. Js I get No route matches GET "/assets/externals. Js" – Anonymous May 27 at 17:52 Restarting the server did the trick!

– Anonymous May 27 at 18:09 So there is no way of doing this without having to maintain two or more manifest files? That seems to go against the Rails Way of convention over configuration in a massive way, no? – beseku May 28 at 1:35.

I believe you can put a library. Js in your in vendor/assets/javascripts and then simply //= require library. Js from your application.

Js, no?

2 Pardon me, should be vendor/assets/javascripts – muxcmux Jun 6 at 12:12 Yeah, at the moment I use two files, (for bug tracking primarily), a vendor. Js and an application.js. I never solved the problem of being able to include all directly to the application.

Js manifest without another manifest file though. – beseku Jun 6 at 14:59.

My answer applies to Rails 3.1rc4, I don't know whether it functions the same with other versions. You can actually put all require statements in app/assets/javascripts/application. Js whether or not the .

Js files are in app/assets/javascripts/ or vendor/assets/javascripts/ Like so: // this is in app/assets/javascripts/application. Js //= require modernizr-2.0 //= require jquery //= require jquery_ujs //= require jqueryui-1.8.12 //= require jquery. Easing-1.3 //= require jquery.

Noisy //= require jquery. Jslide-1.0 //= require respond //= require smoke //= require_tree I included require_tree here because I have other javascript files for my individual controllers (pages.js. Coffee, users.js.

Coffee) and a general one for site-wide stuff (site.js. Coffee) Meanwhile here's the file structure. App/ ├── assets │ ├── javascripts │ │ ├── application.

Js │ │ ├── pages.js. Coffee │ │ ├── users.js. Coffee │ │ └── site.js.

Coffee │ └── stylesheets └── plugins vendor/ ├── assets │ ├── javascripts │ │ ├── jquery. Easing-1.3. Js │ │ ├── jquery. Jslide-1.0.

Js │ │ ├── jquery.noisy. Js │ │ ├── jqueryui-1.8.12. Js │ │ ├── modernizr-2.0.

Js │ │ ├── respond. Js │ │ └── smoke. Js │ └── stylesheets └── plugins This allows me to control the load order of vendor libraries (which matters a lot, usually) and not worry about my internal javascript, where order generally matters less.

More importantly, I control all require statements within one often used file, I find that both safer and cleaner.

1 for this way of handling assets dependencies. This is in the Rails' way as per the guides guides.rubyonrails. Org/asset_pipeline.

Html#asset-organization. Also remember to restart your Rails server after moving files around! – BrutusCat Oct 13 at 10:28.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions