Question

I am using Adobe Edge with Rails and getting 404s on my production server for some Javascript files (everything works fine on development server).

These are my javascript files

application.js
edge.1.5.0.min.js
ink-falling_edge.js.erb
ink-falling_edgeActions.js
ink-falling_edgePreload.js.erb

in application.js

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .

edge.1.5.0.min.js, ink-falling_edge.js.erb and ink-falling_edgeActions.js are failing to load. They are supposed to be dynamically loaded by ink-falling_edgePreload.js.erb.

In ink-falling_edgePreload.js.erb I have:

function loadResources(a,d) {
  AdobeEdge.preload = AdobeEdge.preload || [];
  AdobeEdge.preload.q = AdobeEdge.preload.q || [];
  d || !isCapable() ? filesToLoad = a : AdobeEdge.preload.busy ? AdobeEdge.preload.q.push({files:a, callback:edgeCallback}) : AdobeEdge.requestResources(a,edgeCallback)
}

 aLoader = [
  { load: "<%= asset_path('edge.1.5.0.min.js') %>" },
        { load: "<%= asset_path('ink-falling_edge.js.erb') %>" },
        { load: "<%= asset_path('ink-falling_edgeActions.js') %>" }];

doDelayLoad=false;

loadResources(aLoader, doDelayLoad);

I only modified aLoader to use asset_path, the rest is generated Adobe Edge code.

When I load my page. I get this in the Javascript console:

GET http://.../assets/ink-falling_edge-deca9b287a7502bef69078b737f58a0b.js 404 (Not Found) application-419438724fb62a953134d8263f3f4882.js:8
GET http://.../assets/ink-falling_edgeActions-9bdaa1845a29b15bd2562058432de721.js 404 (Not Found) application-419438724fb62a953134d8263f3f4882.js:8
GET http://.../assets/edge.1.5.0.min-610ab04bb1d4d0ad9a2a845821f04bdf.js 404 (Not Found) application-419438724fb62a953134d8263f3f4882.js:8
GET http://.../assets/edge.1.5.0.min-610ab04bb1d4d0ad9a2a845821f04bdf.js 404 (Not Found) application-419438724fb62a953134d8263f3f4882.js:8
GET http://.../assets/ink-falling_edge-deca9b287a7502bef69078b737f58a0b.js 404 (Not Found) application-419438724fb62a953134d8263f3f4882.js:8
GET http://.../assets/ink-falling_edgeActions-9bdaa1845a29b15bd2562058432de721.js 404 (Not Found) application-419438724fb62a953134d8263f3f4882.js:8

If I comment out the dynamic loading part, the Adobe Edge animation doesn't work.

Is there anything I'm doing wrong in referencing these Javascript files that's causing a 404?

Thanks!

Was it helpful?

Solution

I can't say for sure, but I suspect you haven't updated your application.rb to precompile these files as standalone JS.

Any Javascript or CSS file that you need to access with a direct URL (which is what your load script is doing) needs to be added to the config.assets.precompile in the application.rb. So you need to add a line line this:

config.assets.precompile += %w[edge.1.5.0.min.js ink-falling_edge.js ink-falling_edgeActions.js]

By default JavaScript files are not precompiled into assets exposed on URLs - they're just rolled into the application-.js and other controller specific js files that use manifests. If you want to access the URL directly you need to add it to this list.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top