I have been trying to use Carrierwave for image uploads which is working fine, I was just wondering how I could have an upload directory for each user i.e:-
uploads/current_user.id/gallery.id/
I have two tables,
images
- id
- title
- desc
- gallery_id
- created_at
- updated_at
galleries
- id
- title
- desc
- user_id
- created_at
- updated_at
many thanks
Since you’ve provided very little in the way of specifics about your setup, I will make assumptions with my answer.
If you have some
Gallerymodel which the uploader in question is bound to, the uploader has amodelmethod that returns theGalleryinstance. I will also assume yourGalleryinstance has anownerrelation for someUserrecord. All you need to do is add astore_dirmethod to your uploader to overload the defaultCarrierWave::Uploader::Baseprovides.