Reputation: 1104
I have configured a carrierwave uploader this way:
class PortraitUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
include CarrierWave::RMagick
# include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"#{Rails.root}/public/images/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def cache_dir
"#{Rails.root}/tmp/uploads"
end
end
And my seeds are like so:
Portrait.create({
main: true,
image: open('http://some-image-out-there.jpg'),
customer: @hatakeda
})
In development works 100%.
When uploading my app to Heroku, I can still use the uploader to manually set images, either by uploading or by sending the url
However thee seed creates image urls that does not display an image - 404 error.
How can I make Carrierwave, Heroku and my seedings work together happily?
Upvotes: 2
Views: 791
Reputation: 1567
Are you trying to store images on heroku? Short answer: you can't, as Heroku is read-only (ephemeral writeable filesystem
). If uploading worked, those files will get wiped during your next deploy or when workers restart for any reason. Have a look Carrierwave store images locally not on s3 at heroku.
Upvotes: 1