Search code examples
ruby-on-railsapicarrierwaveproduction-environment

CarrierWave file not saving in production


I'm using Rails 4.2.6 and CarrierWave 1.0.0. I have an uploader setup like so:

class LetterUploader < CarrierWave::Uploader::Base
    storage :file
    def store_dir
        "#{Rails.root}/public/uploads/#{model.id}"
    end
end

In development, the file saves just fine, in /public/uploads/etc..., but in production, it's not saving. It is getting cached, there is a file in the /tmp directory, but not actually being saved. I've looked all over for a solution, and I can't seem to find one. My intuition was that it was a folder permission issue in my production server, but I made sure that the public folder recursively belonged to my user name, and that didn't help. I even set permissions to 777, to no avail. I can provide more info (on the controller, or anything else) on request, any help is appreciated.


Solution

  • The problem wasn't with CarrierWave, but with the fact that an uploaded file doesn't store until the model it is attached to is saved. I re-factored so that the model saves, sends the file to the other api, and then updates the original model, and it works!