Update middleware in Rails

前提是你 提交于 2019-12-06 05:23:41

问题


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.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/8796055/update-middleware-in-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!