我正在尝试在我自己的服务器上运行一个非常简单的带有操作文本的页面 CMS。
在开发中一切正常。附件已上传,保存页面模型后我可以看到它。
切换到生产时,上传仍然有效,我可以在本地文件系统上看到该文件,但查看该页面会显示损坏的图像标签。
图片的链接看起来像
http://example.com/rails/active_storage/representations/SIGNED_ID/myimage.png
在我的本地制作中,链接是:
http://localhost:3000/rails/active_storage/disk/gsid/myimage.png?content_type=image%2Fpng&disposition=inline%3B+filename%3D%22myimage.png%22%3B+filename%2A%3DUTF-8%27%27myimage.png
我提供了一个secrete_key_base
列入白名单的主机和所有东西,以使应用程序在生产环境中运行。
我在用:
- 独角兽
- Nginx
- 红宝石 2.6.5
- 导轨 6.0.2.1
我的存储服务是“磁盘”,里面的所有文件和文件夹,包括RAILS_ROOT
运行应用程序的用户所有。
存储.yml:
local:
service: Disk
root: <%= Rails.root.join("storage") %>
路线.rb:
Rails.application.routes.draw do
resources :pages, param: :seo_url, path: 'seite'
get '/index', to: 'application#home', as: :home
root to: 'application#home'
end
生产.rb:
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
有谁知道为什么这不起作用?