All threads / Display Cloudinary image uploads
Ask A Question


You’re not receiving notifications from this thread.

Display Cloudinary image uploads

Nelson Casanova asked in Gems / Libraries


I've been trying to solve a problem I've got when trying to display images from Cloudinary. I setup everyhting accounding to the guide they provide and basically I need to upload images from Trix editor. All this works ok. I can create a new 'post' and add images and I can see them get uploaded to Cloudinary but when I go to the actual post I see a broken link to the image.

It links to something like:

and when I check the image over at Cloudinary the URL should be something like:

My /views/active_storage/blobs/_blob.html.erb file looks like the default:

<figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
  <% if blob.representable? %>
    <%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %>
  <% end %>

  <figcaption class="attachment__caption">
    <% if caption = blob.try(:caption) %>
      <%= caption %>
    <% else %>
      <span class="attachment__name"><%= blob.filename %></span>
      <span class="attachment__size"><%= number_to_human_size blob.byte_size %></span>
    <% end %>

Any ideas how to grab the image from the cloud instead of that weird looking local storage link?

anyone get the answer? thanks. curious I'm having some issue too regarding this.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 54,919+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2021 GoRails, LLC. All rights reserved.