-
Notifications
You must be signed in to change notification settings - Fork 276
Open
Description
Hi,
I would like to be able to auto select the proper uploader based on a condition.
Exemple
class MyModel
include ApplicationUploader::Attachment.new(:file)
private
def #{column_name}_dynamic_uploader
if ....
ImageUploader
elsif ...
VideoUploader
else
...
end
end
end
Right now it seems I am forced to define. multiple column based on the file type
Things I have tried
Overriding "#{column}_attacher"
like so
define_method(:"#{column}_attacher") do |**options|
if respond_to?(:"#{column}_uploader_class", true)
uploader_class = send(:"#{column}_uploader_class")
uploader_class::Attacher.from_entity(self, column, **options)
else
super(**options)
end
end
For some reason, files don't persist when it doesn't go through the super(...)
conditional branch.
Metadata
Metadata
Assignees
Labels
No labels