在Rails中更新中间件 [英] Update middleware in Rails

查看:73
本文介绍了在Rails中更新中间件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以在Rails中修改(替换)中间件吗?

Is there any way to MODIFY (NOT replace) a middleware in 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 从黄瓜​​运行时打印大量消息.

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

推荐答案

我最后得到了:

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

这对我的特定情况有效( Dragonfly使用了Rails缓存,并且不再插入).

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.

这篇关于在Rails中更新中间件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆