I've got a strange situation. Which is why I end up posting on Stackoverflow...
Basically, I've got a Ruby on Rails 6.1 app, running in production, on which I recently implemented Cloudinary (replacing Amazon S3). Cloudinary allows to get optimised pictures with custom sizes and format, so it's pretty amazing to use.
But I've got a problem with the cl_image_tag
.
When running my code in local environment :
Putting this in development.rb :
config.active_storage.service = :local
Causes this tag to fail to get the picture. Becauses it misses the main folder in which the image is stored (my_app/)
<%= cl_image_tag("homepage/banner.webp", quality: 'auto', width: 1932, height: 904) %>
So I have to write this instead if I want it to work :
<%= cl_image_tag("my_app/homepage/banner.webp", quality: 'auto', width: 1932, height: 904) %>
BUT if I do that, then my production environment will fail because it uses :
development.rb :
config.active_storage.service = :cloudinary
index.html.erb :
<%= cl_image_tag("homepage/banner.webp", quality: 'auto', width: 1932, height: 904) %>
.env :
MEDIA_FOLDER_NAME_IN_CLOUDINARY=my_app
So I find myself stuck between one config working only in local, and one working only in production. What the heck ?! What am I missing ? I can't find anything on StackOverflow or Cloudinary's documentation.
Edit:
My first guess is that the MEDIA_FOLDER_NAME_IN_CLOUDINARY
env variable is only loaded in the code if this line appears :
config.active_storage.service = :cloudinary
But I can't use that in my local environment, so I have to find a workaround...
Thanks in advance for any help people