问题
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