I am using carrierwave and fog gem for uploading files to s3.
In my app user can select their own aws credentials for saving their files. so I cant use initializer. All the credentials will be saved on database with their user ID.
I have made a check in AvatarUplaoder to set the storage type.
def self.call_set_storage_type
active_type=UploadManagement.find_by_is_active(1)
if active_type.nil?
:file
else
if active_type.provider == "aws"
:fog
else
:file
end
end
end
storage call_set_storage_type
I want to make a method in ApplicationHelper or ApplicationController so that I can call it on AvatarUploader. I tried incuding application_helper in avatar_uploader but it didn't worked.
I want to make method in application_helper or applciation_controller because I need that method at many places and also I have other uploaders also to make code DRY I need to call but I am not able to think it.
I checked the documentation also different storage for each uplaoder
Please guide me how can I do that or any alternate solutions are also welcome.