views:

662

answers:

3

Hi,

I'm using paperclip by thoughtbot for attachments to models and everything works fine on my development machine running mac os x and mongrel. However when I deploy may app to a debian machine running apache/mod_rails (2.2.5) I can't get it started. I get 'undefined method has_attached_file' (or 'uninitialized constant Paperclip' using an initializer). I'm sure there is an easy solution but I appear to be blind... Any hints? Thanks!

A: 

Make sure you have this gem properly installed on target machine. If you used REE when installing Passenger then you need to install gems with gem-e instead of gem. In short:

sudo gem-e install paperclip

Bragi Ragnarson
Bragi, thanks! I dont use the ruby enterprise edition so I don't think it'll help :( any other idea? Cheers!
Chris
A: 

I would suggest just 'vendoring' your gems. Just require the gems you use in your environment.rb file using config.gem syntax (you can search online for more specific instructions) and then once those entries are in there, just run 'rake gems:unpack' and the gems you have installed that are required for the app (via the config.gem entries) will be put in vendor/gems.

This way your app will always know where to find your gems...

Shane Liebling
Thank you Shane! I thought of this as well but would like to keep my app as small as possible. It feels redundant to have the gem installed and then again have it in my app... But I'll have to do this if I don't find another solution. Cheers!
Chris
A: 

Blind was right! I finally solved the issue by specifying the paperclip gem thru the proper config.gem entry in environment.rb. I maintain two different environment.rb files, one for development, the other for the production server and I forgot to add the paperclip config.gem line to the latter... Too bad, sorry for bothering you and thanks heaps for answering! Cheers!

Chris