V
V
vadimstroganov2015-11-08 02:13:55
Ruby on Rails
vadimstroganov, 2015-11-08 02:13:55

Uploading carrierwave files to a subdomain?

Hello!
I dug out config.asset_host in the settings, and there you can specify which domain will be added to the path to the file
. But I don’t understand how to upload files to a subdomain (adjacent folder with the project), and so that later I pull out a link through image_url, that subdomain is taken, and accordingly the path to the file?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Sapozhnikov, 2015-11-12
@Skarm61

This parameter is not intended for uploaded files, but for application assets - styles, js code, icons.
Carrerwave can be used with S3 to store files not on the machine where the application is running. Or what do you mean by uploading to a subdomain?
To upload to a different folder on the machine, you need to configure the carrierwave uploader

class FileUploader < CarrierWave::Uploader::Base

  def store_dir
    model_class = model.has_attribute?(:type) ? model.type : model.class.to_s
    "uploads/#{model_class.underscore}/#{mounted_as}/#{model.id}"
  end

end

store_dir can contain both a relative path (like here) and an absolute path

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question