0

I encountered the following problem in the working draft. Initially was not properly selected directory structure to store files using carrierwave. Now you need to change the directory for existing files and rename them (the names are not unique).

Tried to do as described here

Get the error:

ArgumentError: wrong number of arguments (1 for 0)
    from /team/mss/app/uploaders/route_point_photo_uploader.rb:30:in `swap_out_store_dir'

Old code:

def store_dir      
  "uploads/#{model.class.to_s.underscore}/#{model.id}"
end
def filename
  "photo.jpg" if original_filename
end

New code:

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
Community
  • 1
  • 1
  • Can you post your full uploader code? It's giving an error for a specific line, maybe if we see that someone can help you? – Pete Hamilton Jul 25 '14 at 09:29
  • I solved the problem as follows. First, using carrierwave renamed files - giving them unique names uid. Then moved all the files from subfolders in the directory "uploads / # {model.class.to_s.underscore}". Then he changed the directory in the file route_point_photo_uploader.rb. And remove all the unnecessary subfolders. Thank you for your attention. – galievruslan Jul 25 '14 at 09:45

0 Answers0