2

How do I make the single image uploader do different actions depending on the model it is creating the image for?

I have one image uploader, and I want to upload images for Users and for Posts. For the user, I want the original image & thumbnail (70x70). For the Posts, I want the original image and featured thumbnail (260x180). I could just make 3 versions for every image and just call the desired one, but that's probably really bad since it would clog my storage database.

I looked at: Carrierwave; multiple uploaders or just one? and it looks like a possible solution is to create subclasses. However, I wasn't too sure how I would do this - I tried doing it as the answer suggested but with no success.

Community
  • 1
  • 1
kibaekr
  • 1,319
  • 1
  • 21
  • 38

1 Answers1

2

You should use separate carrierwave uploaders since the behaviors are different. There's no need of subclass here unless you want to share some codes between these two uploaders.

Just add another uploader which should be the same of your existing one besides the version part.

nil
  • 3,421
  • 2
  • 21
  • 21