Relative path incorrect in the view layer when hosting a rails3 app in a subdirectory using passenger and apache
Posted
by
Saifis
on Server Fault
See other posts from Server Fault
or by Saifis
Published on 2012-04-29T04:21:10Z
Indexed on
2012/09/27
15:39 UTC
Read the original article
Hit count: 214
I want to host multiple Rails apps on a multiple server using sub-directories. And have encountered some relative path problems.
I have made a symbolic link to the app's public directory and placed it in the /var/www/html directory,
var/www/html/
/test_app (symbolic link to the public folder of test_app)
and set apache as so
LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.12/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.12
PassengerRuby /usr/local/bin/ruby
<VirtualHost *:80>
ServerName test.com
DocumentRoot /var/www/html
Options Indexes FollowSymLinks -MultiViews
RailsBaseURI /test_app
</Location>
</VirtualHost>
The links in the app itself works just fine, all the links acknowledge the test_app/ directory and work, however, when it comes to showing images in the public directory in the view, the relative path goes wrong.
Say I have
/system/files/1/aaa.png
it goes looking for it in
/var/www/html/system/files/1/aaa.png
rather than
/var/www/html/test_app/system/files/1/aaa.png
As far as I understand this is an Apache setting problem than something to be done in Rails, if its possible I would prefer to have it contained in the conf file of apache rather than having to alter the code.
© Server Fault or respective owner