更新 Rails 中的中间件
有没有办法修改(不替换)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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为对于这个特定的中间件,您可以将 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
我最终得到:
这适用于我的特定情况(Rails 缓存由 Dragonfly 使用,并且未插入不再)。
我不认为有办法做我最初要求的事情。
I ended up with:
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.