2
votes

I'm testing rails app deployment with apache2 and phusion passenger 4. This is my apache conf:

    <Location /myproject>
            ProxyPass http://localhost:3000
            ProxyPassReverse http://localhost:3000
    </Location>

then I start passenger in standalone mode in myproject directory:

passenger start -a 127.0.0.1 -p 3000 -d

When I point my browser to https://mydomain.com/myproject the home page shows up correctly but no css or js is loaded because the links to the assets are like:

<link href="/assets/application.css?body=1" media="all" rel="stylesheet" type="text/css">

which points to:

https://mydomain.com/assets/application.css

but should be:

https://mydomain.com/myproject/assets/application.css

How can fix this on apache or rails side?

1
i can use map '/myproject' do in config.ru to remap the base url but this will not fix the url to the assets - shoen
if I set config.assets.enabled = false and config.asset_path = proc { |path| "/myproject#{path}" } in application.rb i will get correct path to my assets but tey will not be generated automatically. how can this be avoided? - shoen
If you are using rails 3.1 or later, are you precompiling your assets? - ctilley79
Yes, I already ran rake assets:clean and rake assets:precompile, the problem is that if you set config.assets.enabled = false only application.css and application.js are present in the page's header. - shoen
That's correct. If you set that to false, then you are no longer using the asset pipeline, therefore the paths will no longer work. stackoverflow.com/questions/8389204/… - ctilley79

1 Answers

2
votes

The solution was simple:

config.relative_url_root = "/myproject"

in application.rb

this fixed path of the assets without disabling the assets pipeline.