Ruby on rails Rails 6:ActionText附加的图像未在_blob部分模板中呈现

Ruby on rails Rails 6:ActionText附加的图像未在_blob部分模板中呈现,ruby-on-rails,rails-activestorage,ruby-on-rails-6,actiontext,Ruby On Rails,Rails Activestorage,Ruby On Rails 6,Actiontext,我目前正在开发一个Rails 6应用程序,其中我使用cloduinary来托管图像。我有一个带有丰富文本内容的模型 class Question < ApplicationRecord belongs_to :user has_many :comments, as: :commentable has_rich_text :content end cl\u image\u标记(blob.key,format::jpg)应该呈现附件文件,但它没有呈现如下图所示的内容 然而,如果

我目前正在开发一个Rails 6应用程序,其中我使用cloduinary来托管图像。我有一个带有丰富文本内容的模型

class Question < ApplicationRecord
  belongs_to :user
  has_many :comments, as: :commentable
  has_rich_text :content
end
cl\u image\u标记(blob.key,format::jpg)
应该呈现附件文件,但它没有呈现如下图所示的内容

然而,如果我把所有的事情都记下来,只有下面这句话<代码>。图像是在没有来自
\u blob.HTML.erb
的HTML结构的情况下呈现的。


为什么
\u blob.html.erb
没有呈现来自Cloudinary的附加图像?

正如您可能已经知道的,部分中的
blob.representable?
方法调用返回
false

如果查看依次调用的源代码,可以看到it检查不包括
image/heic
。您可以将其配置为包含在文档中

config.active\u storage.variable\u content\u types
接受一个字符串数组,表示活动存储可以通过ImageMagick转换的内容类型。默认值为
%w(image/png image/gif image/jpg image/jpeg image/pjpeg image/tiff image/bmp image/vnd.adobe.photoshop image/vnd.microsoft.icon image/webp)

包括
image/heic
并重新启动应用程序后,图像应显示出来

注意:以上链接指向的是
主机
分支。您可能希望根据所使用的rails版本选择正确的标记

希望这有帮助

<div class="border-t-2 border-gray-600 text-2xl m-auto w-4/5">
    <div class="h-56 my-8">
      <%= @question.content %>
    </div>
  </div>
<figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
  <% if blob.representable? %>
      <div class="max-w-xl mx-auto rounded overflow-hidden shadow-lg">
        <%= cl_image_tag(blob.key, format: :jpg )%>
        <div class="px-6 py-4">
          <figcaption class="attachment__caption">
            <% if caption = blob.try(:caption) %>
              <%= caption %>
            <% else %>
              <div class="inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2">
                <span class="attachment__name"><%= blob.filename %></span>
                <span class="attachment__size"><%= number_to_human_size blob.byte_size %></span>
              </div>
            <% end %>
          </figcaption>
        </div>
      </div>
  <% end %>
</figure>