【问题标题】:Ruby on Rails - PDF not showing in production mode with DockerRuby on Rails - PDF 未在 Docker 的生产模式下显示
【发布时间】:2022-08-09 23:22:47
【问题描述】:

我很难找出解决问题的方法。 我有一个在 Docker 中运行的 ror 应用程序。在开发中,上传的 pdf 存储在 ./storage 目录中,并且它们在我的应用程序中按预期呈现。在生产中,上传到同一目录中,但它们不会显示。 我检查了目录和文件的权限,它们似乎没问题。

我的配置:

storage.yml :

local:
  service: Disk
  root: <%= Rails.root.join(\"storage\") %>

production.rb :

config.active_storage.service = :local

_attachment.html.erb :

<% if territory.file.previewable? %>
  <div class=\"container\">
    <embed type=\"application/pdf\" src=\"<%= rails_blob_path(@territory.file, disposition: :inline) %>\" width=\"100%\" height=\"500px\">
  </div>
<% end %>

这部分在我的视图中呈现如下:

<p>
  <%= render \"territories/attachment\", territory: territory %>
</p>

我错过了什么吗? 感谢您的帮助,并保持保存在那里!

    标签: ruby-on-rails ruby docker


    【解决方案1】:

    找到了解决办法!

    Dockerfile 中缺少一些软件包。

    RUN apk add --update --no-cache  --virtual run-dependencies \
    ...
    imagemagick \
    less \
    poppler-utils \
    && rm -rf /var/cache/apk/*
    

    【讨论】:

      猜你喜欢
      • 2013-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多