问题
Behavior:
The Rails app serves up all assets just fine except for those of the dynatree plugin, i.e. my trees don't have folder icons, lines, etc. Firebug reports 404 errors when referencing the asset:
NetworkError: 404 Not Found - http://<production-host>/assets/dynatree/skin/icons-bf773ee37964ed4c51011537fefa5047.gif
I've verified the asset does exist in that directory with that precompiled name.
Because I'm using multiple virtual hosts, I think the URL for the asset should be including the app dir name, i.e.:
http://<production-host>/*houston*/assets/dynatree/skin/icons-bf...
(Asterisks my own for emphasis.)
I've verified that by hitting the url for something like a jqueryui image in the assets subdirectory. If I include the app name in the URL, the image is found just fine. Without it, I get the 404 error, which makes perfect sense.
So why isn't dynatree using the full pathname to the assets directory? It's just concatenating the hostname with /assets. I figure the jquery/dynatree code isn't getting a proper hostname during init time. Any ideas?
Setup:
Multiple hosts setup via Apache/Passenger:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/webapps
<Directory /var/webapps>
AllowOverride None
</Directory>
RailsEnv production
RackBaseURI /houston
<Directory /var/webapps/houston>
Options -MultiViews +FollowSymLinks
Allow from all
</Directory>
Rails/Capistrano:
This is a Rails 3.1 app, deployed using Capistrano and the assets get built by virtue of
load 'deploy/assets' (in deploy.rb)
No changes to default Rails settings for things like config.assets.prefix and such.
Dynatree:
Included via the dynatree-rails gem. Dynatree is otherwise fully functional.
来源:https://stackoverflow.com/questions/18906513/dynatree-unable-to-find-assets-in-rails-production-on-multi-virtual-host-apache