I recently tweaked the code for OmniNerd.com to upgrade it from a Rails 2.3 app to a Rails 3.1 app.  Online docs got me through everything but one item: symbolic links to folder of images (or assets in general).  On OmniNerd, users can upload images.  The site also auto-generates a lot of graphical content.  Our setup is like many, i.e., we deploy with Capistrano and use the shared folder to hold static user content that gets handed off between deployments.  We previously simply had a symlink setup such that:

/path/to/app/current/public/images/content --> /path/to/app/shared/user_uploaded

Now with Rails 3.1, during deployment statics assets are precompiled and end up in the folder:


This wasn’t immediately clear to me because it hadn’t crossed my mind to update the symlink and oddly enough, deploying with the old setup still sort of worked.  By “sort of,” I mean that about 1 in 20 images would come back as a 404.  That’s right, Rails would find some, but not others.  I still have no idea why that’s true, but the fix is quite simple.  I just updated my deploy script to create the following symlink:

/path/to/app/current/public/assets/content --> /path/to/app/shared/user_uploaded

Note: be sure to precompile your assets before creating the link as the /public/assets folder is created on the fly during deployment when you precompile.

Hope that helps someone dealing with the same unpredictable 404s I was experiencing.