diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-07-07 18:38:14 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2010-09-03 22:59:05 +0200 |
commit | 177a4bd5b7f903030a100f9b5092b1fa62c7c748 (patch) | |
tree | 2ca5c7111a952e141bc0baa984876857c9ec9648 /railties/lib/rails | |
parent | 451c9942bb493190d5673c1b55be7506056db13b (diff) | |
download | rails-177a4bd5b7f903030a100f9b5092b1fa62c7c748.tar.gz rails-177a4bd5b7f903030a100f9b5092b1fa62c7c748.tar.bz2 rails-177a4bd5b7f903030a100f9b5092b1fa62c7c748.zip |
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
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/application.rb | 10 | ||||
-rw-r--r-- | railties/lib/rails/engine.rb | 9 |
2 files changed, 10 insertions, 9 deletions
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 diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 22a1a15bf5..401c4ff56b 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -159,13 +159,8 @@ module Rails end def call(env) - app.call(env.reverse_merge!(env_defaults)) - end - - def env_defaults - @env_defaults ||= { - "action_dispatch.routes" => routes - } + env["action_dispatch.routes"] = routes + app.call(env) end def routes |