From f7a1c64ac3b487df8834eff0863a56fa10c18b97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hrvoje=20=C5=A0imi=C4=87?= Date: Wed, 4 Apr 2012 12:09:10 +0200 Subject: removed deprecated methods and middlewares --- guides/source/rails_on_rack.textile | 64 ++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/guides/source/rails_on_rack.textile b/guides/source/rails_on_rack.textile index 73e0f242cc..34dfd3572a 100644 --- a/guides/source/rails_on_rack.textile +++ b/guides/source/rails_on_rack.textile @@ -148,20 +148,50 @@ You can swap an existing middleware in the middleware stack using +config.middle # config/application.rb -# Replace ActionController::Failsafe with Lifo::Failsafe -config.middleware.swap ActionController::Failsafe, Lifo::Failsafe +# Replace ActionDispatch::ShowExceptions with Lifo::ShowExceptions +config.middleware.swap ActionDispatch::ShowExceptions, Lifo::ShowExceptions h5. Middleware Stack is an Array The middleware stack behaves just like a normal +Array+. You can use any +Array+ methods to insert, reorder, or remove items from the stack. Methods described in the section above are just convenience methods. -For example, the following removes the middleware matching the supplied class name: +Append following lines to your application configuration: -config.middleware.delete(middleware) +# config/application.rb + config.middleware.delete "Rack::Lock" + config.middleware.delete "ActionDispatch::Cookies" + config.middleware.delete "ActionDispatch::Flash" + config.middleware.delete "ActionDispatch::RemoteIp" + config.middleware.delete "ActionDispatch::Reloader" + config.middleware.delete "ActionDispatch::Callbacks" +And now inspecting the middleware stack: + + +$ rake middleware +(in /Users/lifo/Rails/blog) +use ActionDispatch::Static +use # +use Rack::Runtime +use Rack::MethodOverride +use ActionDispatch::RequestId +use Rails::Rack::Logger +use ActionDispatch::ShowExceptions +use ActionDispatch::DebugExceptions +use ActiveRecord::ConnectionAdapters::ConnectionManagement +use ActiveRecord::QueryCache +use ActionDispatch::Session::CookieStore +use ActionDispatch::ParamsParser +use ActionDispatch::Head +use Rack::ConditionalGet +use Rack::ETag +use ActionDispatch::BestStandardsSupport +run Myapp::Application.routes + + h4. Internal Middleware Stack Much of Action Controller's functionality is implemented as Middlewares. The following list explains the purpose of each of them: @@ -234,32 +264,6 @@ Much of Action Controller's functionality is implemented as Middlewares. The fol TIP: It's possible to use any of the above middlewares in your custom Rack stack. -h4. Customizing Internal Middleware Stack - -It's possible to replace the entire middleware stack with a custom stack using ActionController::Dispatcher.middleware=. - -Put the following in an initializer: - - -# config/initializers/stack.rb -ActionController::Dispatcher.middleware = ActionController::MiddlewareStack.new do |m| - m.use ActionController::Failsafe - m.use ActiveRecord::QueryCache - m.use Rack::Head -end - - -And now inspecting the middleware stack: - - -$ rake middleware -(in /Users/lifo/Rails/blog) -use ActionController::Failsafe -use ActiveRecord::QueryCache -use Rack::Head -run ActionController::Dispatcher.new - - h4. Using Rack Builder The following shows how to replace use +Rack::Builder+ instead of the Rails supplied +MiddlewareStack+. -- cgit v1.2.3