ruby on rails - Carrierwave; multiple uploaders or just one? -


i have post model , podcast model. both models have attribute titled: image. i'm using 1 carrierwave uploader (named imageuploader) handle both models. have 2 questions before go production.

dumb question:

is ok use same uploader 2 different models when both have same attribute name file attachements? sorry if seems obvious

main question:

i want create 3 versions of each blog post image (thumb, large, sepia) , 1 version of each podcast image (thumb).

do need use 2 uploaders or can namespace 1 i'm using?

again seems obvious. i have written second uploader in time taken me ask these questions

you can use same uploader on different models if have different attribute names. e.g.

class post   mount_uploader :image, imageuploader end  class podcast   mount_uploader :photo, imageuploader end 

whether or not you'd want different matter. in case, i'd create different uploaders each model, because have different requirements. can use subclasses if want keep code dry:

class imageuploader < carrierwave::uploader::base; end  # thumbnail class postimageuploader < imageuploader; end  # thumbnail (from superclass), large & sepia class podcastimageuploader < imageuploader; end # thumbnail (from superclass) 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -