views:

27

answers:

2

I am using Heroku for my production environment so I need to load the paperclip files into different directories.

For development I want it to continue in the current /system default, and in production I want to pass the :path variable to a /tmp directory per Heroku.

How do I do this? Am guessing maybe set something in the environments/production.rb file as a variable for the :path but I'd like to see explicitly how to do it the right way.

Thanks.

Here is a snippet from my controller to create the model after passing the file through a multipart form:

def create
    @contact = Contact.create(params[:contact])

     unless @contact.vcard.path.blank?

           paperclip_vcard = File.new(@contact.vcard.path) 
A: 

In the model holding the attached file there's a method you say it holds that file and some options, etc. In that method you can pass the :path parameter that will tell it where to save it.

Now is just a matter of checking ENV['RAILS_ENV'] to find out what environment you are and set the path accordingly.

Francisco Soto
Hi, where do I pass the parameter. Here is from the create controller:def create @contact = Contact.create(params[:contact]) unless @contact.vcard.path.blank? paperclip_vcard = File.new(@contact.vcard.path) It seems like after the multipart form upload, it gets attached when creating the model instance.
Angela
A: 

Unfortunately Heroku does not support storing application generated files on their servers (read-only) so for your production environment you will have to find some external (to Heroku) storage solution. They have provided details on how to use Amazon's S3 service here by way of an example on how to do this.

bjg