I am using CarrierWave to do Image upload and I am not sure where I should put these files and how I can access these files in my view. I am mainly having this problem in production where the images appear to be missing. It works just fine in development.
Where should I put these files so that it is accessible through URL and from the view? I have tried putting it in 'public/uploads/picture/1/image.jpg' but I still cannot access the image from the url
What is the right way to do this?
class ImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# Choose what kind of storage to use for this uploader:
# storage :fog
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
So I did 'ls -al' inside the folder that contains all the images and this is what I got
drwxr-xr-x 2 root root 4096 Feb 20 23:07 . drwxr-xr-x 4 deployer root 4096 Feb 20 23:07 ..
-rw-r--r-- 1 root root 2313 Feb 20 23:07 doraemon.gif
-rw-r--r-- 1 root root 13367 Feb 20 23:07 profile_doraemon.gif
-rw-r--r-- 1 root root 2313 Feb 20 23:07 shoutout_thumb_doraemon.gif
-rw-r--r-- 1 root root 9201 Feb 20 23:07 thumb_doraemon.gif
It looks like when the file is uploaded. The files are owned by root. The folders and subfolder that contain it are also owned by root. For example, this is the folder that contains the files above.
drwxr-xr-x 2 root root 4096 Feb 20 23:07 7
Also, this is the path the the view/HTML is trying to access
<img alt="Thumb_doraemon" class="" data-id="7" src="/uploads/picture/image/7/thumb_doraemon.gif">
And in the server, the file is located in