Where is the ActionController :: Dispatcher in Rails 3.2?

I follow an example in the Rails 3 path, and when I tried to send a request to the dispatcher in the console, ActionController::Dispatcher.new.call(env).last.body

I got

1.9.3p194 :001 > ActionController::Dispatcher.new.call(env).last.body NameError: uninitialized constant ActionController::Dispatcher'

I used rails 3.2.6, I checked the rails api and found that they removed the dispatcher in the ActionController, but the rail guide says: ActionController :: Dispatcher.new is the main object of the Rails Rails application. Any rack-compatible web server must use the ActionController :: Dispatcher.new object to serve the Rails application.

I find v3.0.7 rails api. The dispatcher still exists in this version.

So here are my questions: how to find equivalent methods like ActionController.Dispatcher.new? and given that my applications work well with rails 3.2.6, what part of the rails now plays the role of ActionController.Dispatcher?

+4
source share
2 answers

This is what Rails rail guides say about the basic objects of a Rack application:

ApplicationName :: Application is the main object of the Rack Rails application. Any rack-compatible web server must use ApplicationName :: Application to serve the Rails application.

So ActionController::Dispatcher.new just been replaced with ApplicationName::Application . I am not sure when they made this switch. This worked for me:

 Blog::Application.call(env).last.body 


(The first few lines after NoMethodError: undefined method 'key?' for nil:NilClass tell us that the key? Method is called in actionpack-3.2.11/lib/action_dispatch/routing/route_set.rb . Going back, we see that the variable

 params = env['action_dispatch.request.path_parameters'] 

not if it should not be. Thus, we can set env['action_dispatch.request.path_parameters'] in the console, but this leads to another NoMethodError for the nil object set in the initialize method. That way, we could fix this by passing a hash of the hash of the Dispatcher.new options, but it is probably best to use ApplicationName::Application .)

+4
source

It has been moved to ActionDispatch (actionpack / lib / action_dispatch) and can be found here: actionpack / lib / action_dispatch / routing / route_set.rb , a class called

 ActionController::Routing::RouteSet::Dispatcher.new 
+3
source

All Articles