title: Reloading rails middleware without restarting the server in development
body: <p>I have a rails 4 app with middleware located at lib/some/middleware.rb which is currently injected into the stack though an initializer like so:</p>
  
  <pre><code>MyApp::Application.configure.do |config|
      config.middleware.use 'Some::Middleware'
  end
  </code></pre>
  
  <p>Unfortunately, any time I change something I need to restart the server. How can I reload it on each request in development mode? I've seen similar questions about reloading lib code with either autoloading or wrapping code in a to_prepare block but I'm unsure how that could be applied in this scenario.</p>
  
  <p>Thanks,
  - FJM</p>
  
  <p><strong>Update #1</strong></p>
  
  <p>If I try to delete the middleware and then re-add it in a to_prepare block I get an error "Can't modify frozen array".</p>