Question

Ok, so I have Ruby on Rails running on an CentOS server and it's working fine. Currently trying to migrate the same app to a Ubuntu server which is working except for a particular folder of images, which I can't seem to figure out what's going on with.

I'm deploying via Capistrano so I'm deploying to current folder. Here's my apache .conf file settings:

<Virtualhost *:80>
    ServerName myserver
   DocumentRoot  /var/www/folder/current/public
   <Directory /var/www/folder/current/public>
      Allow from all
      Options -Multiviews
   </Directory>
</VirtualHost>

The files exist in my app (under assets/vendors). I don't get any errors during building or precompiling or deployment. When trying to serve the files on the new server, I get the following message:

Started GET "/system/vendors/logos/000/000/002/original/filename.png?1354897276" for 68.188.46.74 at 2013-01-25 00:51:37 +0000

ActionController::RoutingError (No route matches [GET] "/system/vendors/logos/000/000/002/original/filename.png"):
  actionpack (3.2.11) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (3.2.11) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'

I have tried permissions changes including 777 the tmp folder (which I would never normally do), just to see if that makes a difference.

It looks like the system assets pipeline folder is in my shared directory, but I don't see a symbolic link to it like I do the logs directory. So I tried creating a symbolic link to it and that didn't do anything.

I'm at a loss. Any suggestions?

EDIT 1/25

When I posted this, I failed to notice it was a paperclip uploaded image and that is why these images are in the system path. So I'm calling them via views from the logo attribute which is defined in the model like so:

  has_attached_file :logo

And in my view, I'm calling it via this:

          <%= image_tag(vendor.logo.url, :class => 'rounded'); %>

Again, this works on two other servers, so the migration is clearing affecting it and I think it may be permissions related?

ImageMagick is installed on the server.

Was it helpful?

Solution

These files aren't being served because Rails will not serve files from the app/assets, lib/assets or vendor/assets directories while it's running in the production environment.

This file should really be located within the public directory, at the path that the request is specifying. By placing it there, you have the added benefit of that the file will be served by the web server that's running Passenger (Apache/Nginx), rather than Rails. This means the request will be substantially faster than if it were served by Rails.

Please ensure that all static files you wish to serve are located in the public directory and its subdirectories for maximum speed.

OTHER TIPS

So ryan's answer was on the right track, but I figured I would fill in the whole details since this may help someone else.

I am using Paperclip for Rails uploads and I'm not sure of the whole cause of this issue, but perhaps it was a Rails update, but anyway, I ended up changing the following settings to move these into the right folder:

has_attached_file :logo, 
:path => ':rails_root/public/uploads/:attachment/:basename..:extension', 
:url => '/uploads/:basename.:extension'

There are more options you can follow, but that worked for my needs.

So now my files end up in my /public/uploads directory, which is working. You will have to manually move any files that you have already uploaded. Locally they will automatically move with you when you deploy.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top