From 177a4bd5b7f903030a100f9b5092b1fa62c7c748 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 7 Jul 2010 18:38:14 +0200 Subject: Fix url generation for mounted Engine I added integration tests for generating urls in Engine and application and tweaked Engines to fully cooparate with new router's behavior: * Rails.application now sets ORIGINAL_SCRIPT_NAME * Rails.application also sets its routes as env['action_dispatch.parent_routes'] * Engine implements responds_to? class method to respond to all the instance methods, like #routes --- railties/lib/rails/application.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'railties/lib/rails/application.rb') diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 4ea828c549..3dba5f78a2 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -121,14 +121,20 @@ module Rails alias :build_middleware_stack :app def call(env) + if Rails.application == self + env["ORIGINAL_SCRIPT_NAME"] = env["SCRIPT_NAME"] + env["action_dispatch.parent_routes"] = routes + end + + env["action_dispatch.routes"] = routes app.call(env.reverse_merge!(env_defaults)) end def env_defaults - @env_defaults ||= super.merge({ + @env_defaults ||= { "action_dispatch.parameter_filter" => config.filter_parameters, "action_dispatch.secret_token" => config.secret_token - }) + } end def initializers -- cgit v1.2.3