ruby on rails - Carrierwave only saves image as tmp in Production-env -


spent whole daying trying work. carrierwaves , fileuploads works fine when doing on development/local-computer, when trying on server env:production , deploying through capistrano files saved in uploads/tmp/ , not stated in image_uploader.

 def store_dir     "#{rails.root}/public/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"   end 

i have tried several things suggested when searced nothing have solved problem.

furthermore form/post not forward me stay on same page uploaded, doesnt happen when in development/local.

here parts deploy.rb thought solve problem:

set :linked_dirs, fetch(:linked_dirs) + %w{public/uploads} 

task :symlink_uploads run "ln -nfs #{shared_path}/uploads #{release_path}/public/uploads" end

 after :restart, :seed_roles, :symlink_uploads  

edit question: have move pictures being uploaded tmp want them stored?

please following

and in set

config/initializers/carrierwave.rb

carrierwave.configure |config|   config.root = rails.root end 

https://github.com/carrierwaveuploader/carrierwave/wiki/how-to:-secure-upload

here not require change store_dir

if want change random hex file name

https://github.com/carrierwaveuploader/carrierwave/wiki/how-to:-create-random-and-unique-filenames-for-all-versioned-files

put below code in uploader

def filename      "#{secure_token(10)}.#{file.extension}" if original_filename.present?   end    protected   def secure_token(length=16)     var = :"@#{mounted_as}_secure_token"     model.instance_variable_get(var) or model.instance_variable_set(var, securerandom.hex(length/2))   end 

hope solve problem


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -