diff options
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/metal.rb | 10 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb index d68fa16847..54980aa453 100644 --- a/actionpack/lib/action_controller/metal.rb +++ b/actionpack/lib/action_controller/metal.rb @@ -259,5 +259,15 @@ module ActionController lambda { |env| new.dispatch(name, ActionDispatch::Request.new(env)) } end end + + # Direct dispatch to the controller. Instantiates the controller, then + # executes the action named +name+. + def self.dispatch(name, req) + if middleware_stack.any? + middleware_stack.build(name) { |env| new.dispatch(name, req) }.call req.env + else + new.dispatch(name, req) + end + end end end diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index c026d0e2d9..3e3a424df3 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -44,7 +44,7 @@ module ActionDispatch end def dispatch(controller, action, req) - controller.action(action).call(req.env) + controller.dispatch(action, req) end end |