0

I have been developing a small app with Sinatra. Locally it works fine but when I deploy it Heroku my JavaScript paths seem to break and I have no idea what is causing this.

My directory set up is I have a "assets" folder in the root of my application with separated folders for both scripts and styles. The scripts folder has a few subdirectories. I have set my public folder in Sinatra using:

set :public_folder, __DIR__ + '/assets'

My styles work correctly and I am drawing a blank on what the problem is. Also worth noting I am using requirejs to load my JavaScript.

Here is the output from the console:

GET http://evening-hamlet-5644.herokuapp.com/scripts/utils/libraries/jquery.js 404 (Not Found) require.min.js:1884
GET http://evening-hamlet-5644.herokuapp.com/scripts/utils/templating/hogan.js 404 (Not Found) require.min.js:1884
2
Uncaught Error: Script error
http://requirejs.org/docs/errors.html#scripterror require.min.js:194
GET http://evening-hamlet-5644.herokuapp.com/scripts/utils/libraries/lodash.js 404 (Not Found) require.min.js:1884
Uncaught Error: Script error
http://requirejs.org/docs/errors.html#scripterror require.min.js:194
GET http://evening-hamlet-5644.herokuapp.com/scripts/utils/libraries/pusher.js 404 (Not Found) require.min.js:1884
Uncaught Error: Script error
http://requirejs.org/docs/errors.html#scripterror 

Any help or a kick in the right direction would be great.

Thanks

4

3 回答 3

4

您可以使用 heroku 工具带(类似于heroku run bash --app <your app name>)运行控制台,并验证您是否有 JS 文件。

问候!

于 2013-06-05T16:34:14.537 回答
0

我不是 Sinatra 黑客,但我在他们的文档中没有找到任何DIR 。尝试将DIR设置为 File.dirname(__FILE__),我在他们的文档中看到了

于 2013-06-05T13:59:49.710 回答
0

如果您发布了呈现指向 javascript 文件的链接的 Sinatra 代码(即 haml 视图等),将会有所帮助。

但是,如果没有代码,我感觉可能是因为您应该使用Sinatra 的urlhelper。如果不是这样,并且您发布代码,我会再看一下。

于 2013-06-06T01:45:40.987 回答