[Mongrel] Update for thread: Multiple rails apps with Mongrel

Josh Richard jrichar4 at d.umn.edu
Wed Jan 31 14:37:07 EST 2007

Hash: SHA1

Tony Rose wrote:
> Josh,
> You caught me, I forgot to document one step that I did... since my
> document root for my domain is:
> /var/www/html/
> For each of the apps, I had to make a symlink from that apps public
> directory to my document root directory... and then the /images and
> /stylesheets loaded as I needed them to, and works as you would expect
> it to when you deploy changes to current...
> --> ln -s /var/www/rails/app1/current/public /var/www/html/app1
> I'll update my blog post now! Thanks for catching it.
> Tony

No problem.

I am still experiencing the issue after the symlink.
However, I think I figured this out and wanted to reiterate findings as
this may be useful to someone else tackling this issue.

Here are some specifics:

In a html file I have a static link as such:

<img src="/images/foo.png"/>

- From mongrel_rails start, I can see the image under:

I deploy the app using capistrano the site is under:


which put the new URL to the image:


Kaboom.  The symlink does not work for the images since they are still
one directory down.

What is interesting is the stylesheets have _always_ worked:

<link href="/app/stylesheets/main.css?1170289309" media="all"
rel="Stylesheet" type="text/css" />

and are generated by the

<%= stylesheet_link_tag "main", :media => "all" %>

call to ERB.

This was the key!  For each image link or URL reference in my site (not
that many really), I modified the static links to use  img_tag and
link_to in ERB as:

<%= image_tag('foo') %><br>
<%= link_to 'Home', :action => "list" %>

This makes sense as image_tag assumes a path images relative to the root
of the project.  Since mongrel is running with the --prefix of app
everything happens as expected and we have:

in mongrel_rails start:

after deployment with capistrano:

I am not sure the symlink is the right recommendation as this could be
fixed by allowing ERB to generate URLS.  I was able to find supportive
evidence in the agile web development with rails skateboarding book, p 41.

Thanks again.

Josh Richard
University of Minnesota Duluth
Version: GnuPG v1.4.6 (GNU/Linux)


More information about the Mongrel-users mailing list