From 6c906bf59111e09997787c1d4c5ba2ec2b783cdd Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 1 Sep 2010 19:31:29 +0200 Subject: [PATCH] Use default_scope in isolated Engines to not force user to scope his routes --- railties/lib/rails/engine.rb | 2 ++ railties/test/railties/engine_test.rb | 18 +++++++----------- railties/test/railties/mounted_engine_test.rb | 8 +++----- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index be63363242..1990aa5261 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -303,6 +303,8 @@ module Rails end end + self.routes.default_scope = {:module => name} + self.namespaced = true end diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index 73d9b61719..3049011477 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -390,14 +390,12 @@ module RailtiesTest @plugin.write "config/routes.rb", <<-RUBY Bukkits::Engine.routes.draw do - scope(:module => :bukkits) do - match "/foo" => "foo#index", :as => "foo" - match "/foo/show" => "foo#show" - match "/from_app" => "foo#from_app" - match "/routes_helpers_in_view" => "foo#routes_helpers_in_view" - match "/polymorphic_path_without_namespace" => "foo#polymorphic_path_without_namespace" - resources :posts - end + match "/foo" => "foo#index", :as => "foo" + match "/foo/show" => "foo#show" + match "/from_app" => "foo#from_app" + match "/routes_helpers_in_view" => "foo#routes_helpers_in_view" + match "/polymorphic_path_without_namespace" => "foo#polymorphic_path_without_namespace" + resources :posts end RUBY @@ -514,9 +512,7 @@ module RailtiesTest @plugin.write "config/routes.rb", <<-RUBY Bukkits::Engine.routes.draw do - scope(:module => :bukkits) do - resources :posts - end + resources :posts end RUBY diff --git a/railties/test/railties/mounted_engine_test.rb b/railties/test/railties/mounted_engine_test.rb index 1df6326d26..b1e3e274b8 100644 --- a/railties/test/railties/mounted_engine_test.rb +++ b/railties/test/railties/mounted_engine_test.rb @@ -56,11 +56,9 @@ module ApplicationTests @plugin.write "config/routes.rb", <<-RUBY Blog::Engine.routes.draw do - scope(:module => :blog) do - resources :posts do - get :generate_application_route - get :application_route_in_view - end + resources :posts do + get :generate_application_route + get :application_route_in_view end end RUBY