更新 Rails 中的中间件

发布于 2024-12-25 13:26:39 字数 497 浏览 5 评论 0原文

有没有办法修改(替换)rails 中的中间件?

因此,

config.middleware.delete ::Rack::Cache
config.middleware.use ::Rack::Cache, :metastore => "rails:/", :entitystore => "rails:/", :verbose => false

我只想简单地编写类似 config.middleware.find!(::Rack::Cache).verbose = false 的内容。

更新:这样做的原因是因为 capybara-webkit 从 Cucumber 运行时打印大量消息

Is there any way to MODIFY (NOT replace) a middleware in rails?

So instead of:

config.middleware.delete ::Rack::Cache
config.middleware.use ::Rack::Cache, :metastore => "rails:/", :entitystore => "rails:/", :verbose => false

I want to simply write something like config.middleware.find!(::Rack::Cache).verbose = false.

UPDATE: The reason to do it is because the capybara-webkit prints tons of messages when running from cucumber.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

许久 2025-01-01 13:26:39

我认为对于这个特定的中间件,您可以将 Rack 环境选项设置为与其默认配置合并,如下所示: http://rtomayko.github.com/rack-cache/configuration

I think for this particular middleware, you can set the Rack environment option to be merged with its default configuration as per: http://rtomayko.github.com/rack-cache/configuration

羁〃客ぐ 2025-01-01 13:26:39

我最终得到:

  # Disable annoying Cache messages:
  config.action_controller.perform_caching = true
  config.action_dispatch.rack_cache = {:metastore => "rails:/", :entitystore => "rails:/", :verbose => false}

这适用于我的特定情况(Rails 缓存由 Dragonfly 使用,并且未插入不再)。

我不认为有办法做我最初要求的事情。

I ended up with:

  # Disable annoying Cache messages:
  config.action_controller.perform_caching = true
  config.action_dispatch.rack_cache = {:metastore => "rails:/", :entitystore => "rails:/", :verbose => false}

This worked for my particular case (Rails cache was used by Dragonfly and wasn't inserted anymore).

I don't think there is a way of doing what I originally asked though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文