From ec6638a23756ea104f203546df15a5e3e0dff229 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 15 Sep 2015 07:38:39 -0700 Subject: allocate request objects with the env hash, set routes on the request This commit is to abstract the code away from the env hash. It no longer needs to have the routes key hard coded. --- actionpack/lib/action_controller/metal.rb | 7 ------- actionpack/lib/action_controller/renderer.rb | 8 ++++++-- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb index 030a1f3478..0384740fef 100644 --- a/actionpack/lib/action_controller/metal.rb +++ b/actionpack/lib/action_controller/metal.rb @@ -140,13 +140,6 @@ module ActionController end end - def self.build_with_env(env = {}) #:nodoc: - new.tap { |c| - c.set_request! ActionDispatch::Request.new(env) - c.set_response! make_response!(c.request) - } - end - # Delegates to the class' controller_name def controller_name self.class.controller_name diff --git a/actionpack/lib/action_controller/renderer.rb b/actionpack/lib/action_controller/renderer.rb index 2a8b19b7ca..e4d19e9dba 100644 --- a/actionpack/lib/action_controller/renderer.rb +++ b/actionpack/lib/action_controller/renderer.rb @@ -65,14 +65,18 @@ module ActionController @controller = controller @defaults = defaults @env = normalize_keys defaults.merge(env) - @env['action_dispatch.routes'] = controller._routes end # Render templates with any options from ActionController::Base#render_to_string. def render(*args) raise 'missing controller' unless controller - instance = controller.build_with_env(@env) + request = ActionDispatch::Request.new @env + request.routes = controller._routes + + instance = controller.new + instance.set_request! request + instance.set_response! controller.make_response!(request) instance.render_to_string(*args) end -- cgit v1.2.3