Reputation: 6108
I'm using unicorn to serve a sinatra application, and the frontend is using bootstrap.js and jQuery(UI).
Currently, when I run the application on my local machine and access the page from my local machine, all is as it should be. However, I've had coworkers connect from their machines on the LAN, and their results are different. It is a little unclear exactly what loads and what doesn't, but one thing is sure: not all of the JavaScript is going to remote machines. The home page uses jQueryUI tabs, but when the page is loaded on any host but the server, it renders without them (instead, there is a bulleted list with links).
The .js
files are referenced by normal HTML <script>
tags in ERB files that are served by Sinatra.
The output from unicorn suggests that the js files are getting requested and sent correctly (I am getting HTTP 200 status for each):
xxx.xxx.xxx.xxx - - [18/May/2012 09:41:12] "GET /js/jquery-1.7.2.min.js HTTP/1.1" 200 94840 0.0257
xxx.xxx.xxx.xxx - - [18/May/2012 09:41:12] "GET /js/jquery-ui-1.8.20.custom.min.js HTTP/1.1" 200 206731 0.0113
xxx.xxx.xxx.xxx - - [18/May/2012 09:41:12] "GET /js/bootstrap.js HTTP/1.1" 200 50089 0.0056
The local permissions on each file are 755, and they are located in [app_root]/public/js.
There's obviously a possibility that my issue isn't with Sinatra or Unicorn, but this is my context at the moment. Please let me know if there's something I should look into, or if more information should be added to the question.
Upvotes: 2
Views: 592
Reputation: 6108
I've managed to get things to work, but in a way that leaves me still curious what was causing the issue in the first place.
I had been running Unicorn on my local machine, which is a MacBook Pro. I decided to spin up an AWS instance with an Ubuntu image and install the app there (which is the intended use case once the application is done). Without changing the configuration at all, the application works perfectly on the AWS node. Apparently the MBP doesn't know how to be a web server.
If anyone has an insights into why this might be, I'd love to hear them, but I'm going to accept this answer because the issue is resolved for me.
Upvotes: 0
Reputation:
I think problem is in DSL links, Sinatra doesn't understand that /js/jquery-1.7.2.min.js
route if you don't have it described in your code, but as soon as it's static file you can do this:
set :public, File.dirname(__FILE__) + '/js'
this tells Sinatra that all files in your /js
folder are static and it should served in proper way
Upvotes: 1