Active Storage _blob partial not being respected or loaded

Viewed 267

I am trying to edit app/views/active_storage/blobs/_blob.html.erb, the partial file created when installing active_storage which allows you to customise how blobs appear inside action_text output.

On other projects, this has worked without issue, on a new Rails 7 project it would appear that the partial added during install is being ignored, as such no edits are coming through.

I can see this by making a small text change (so not adding an HTML element which may get stripped).

For example, I've added "this is a test" in a few places, this does not show:

app/views/active_storage/blobs/_blob.html.erb:

<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 %>
      this is a test
    <% else %>
      <span class="attachment__name"><%= blob.filename %></span>
      <span>this is a test</span>
      <span class="attachment__size"><%= number_to_human_size blob.byte_size %></span>
    <% end %>
  </figcaption>
</figure>

In other projects, when you view the log output in development it will correctly say "rendered app/views/active_storage/blobs/_blob.html.erb", on this project it doesn't.

File uploads work via actiontext, and rendering the file works by way of the built-in partial, but I can't get the customisable version to be viewed at all.

This is happening on both development and production environments, so I don't think it is anything like a weird eager loading/caching issue.

Does anyone have any ideas as to where I could start looking to debug this further?

  • rails: 7.0.2.3
0 Answers
Related