【问题标题】:Rails Active Storage KeyError: Missing configuration for the Active Storage serviceRails Active Storage KeyError:缺少 Active Storage 服务的配置
【发布时间】:2022-11-28 07:55:25
【问题描述】:

更新:

如果我在控制台中运行相同的操作两次,第一次失败,第二次成功!

这发生在我们从 5.2 升级到 Rails 7.0.3 时

之前一切正常,我知道 YAML 文件是正确的。

任何主动存储操作都会给我们:

KeyError: Missing configuration for the  Active Storage service. Configurations available for the local, test, amazon, and amazonDemo services.

存储.yml:

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

在测试.rb 中:

config.active_storage.service = :test

(我们在所有环境中都正确设置了这些。就像我说的,它在升级之前就可以工作)

我感兴趣的是错误消息中的双空格。似乎并未真正设置活动存储服务。我查看了 Edge Guides 以及我能找到的所有教程。感觉不需要任何其他配置。我正式被难住了。

红宝石:2.7.6 轨道 7.0.3

我确实在这里发现了一个类似的问题:

https://github.com/rails/rails/issues/43145

【问题讨论】:

    标签: ruby-on-rails ruby rails-activestorage


    【解决方案1】:

    我们的 blob fixtures 没有设置 service_name。它抱怨 blob 没有服务。

    【讨论】:

      【解决方案2】:

      升级到 6.1 后我遇到了类似的问题。 new active storage update 添加了一个名为 service_name 的新列。

      我在 fixtures 文件夹的 active_storage_blobs.yml 中添加了 service_name: test 并且它有效

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-11-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-12-27
        • 2021-09-14
        • 1970-01-01
        • 2019-09-17
        相关资源
        最近更新 更多