Answer the question
In order to leave comments, you need to log in
Rails + Carrierwave how to move to another directory and rename files?
Hello
I ran into the following problem in a working project. It is necessary to change the directory structure for images loaded via carrierwave. Rested against the ceiling of the nix file system in 32000 directories.
Now the files are uploaded to the directory:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{model.id}/"
end
def filename
"photo.jpg" if original_filename
end
def store_dir
"uploads/#{model.class.to_s.underscore}/"
end
def filename
"#{secure_token}.jpg" if original_filename
end
protected
def secure_token
var = :"@#{mounted_as}_secure_token"
model.instance_variable_get(var) or model.instance_variable_set(var, SecureRandom.uuid)
end
RoutePointPhoto.all.each do |image|
image.photo.cache!
image.photo.store!
end
ArgumentError: wrong number of arguments (1 for 0)
from /team/mss/app/uploaders/route_point_photo_uploader.rb:30:in `swap_out_store_dir'
Answer the question
In order to leave comments, you need to log in
In general, I solved the problem in two stages:
1) Rename the files as described here
2) Move the files with the command
3) Change the directory in the uploader file
def store_dir
"uploads/#{model.class.to_s.underscore}/"
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question