aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-09-15 07:38:39 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-09-15 07:38:39 -0700
commitec6638a23756ea104f203546df15a5e3e0dff229 (patch)
tree492a9b5b8c37a1573afa42f62e415d4e21cec2b7 /actionpack/lib
parenta50376424f9e72eba0d816ca303034ce03b6fe84 (diff)
downloadrails-ec6638a23756ea104f203546df15a5e3e0dff229.tar.gz
rails-ec6638a23756ea104f203546df15a5e3e0dff229.tar.bz2
rails-ec6638a23756ea104f203546df15a5e3e0dff229.zip
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.
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/metal.rb7
-rw-r--r--actionpack/lib/action_controller/renderer.rb8
2 files changed, 6 insertions, 9 deletions
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' <tt>controller_name</tt>
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