diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-09-25 19:02:14 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2010-09-30 09:47:05 +0200 |
commit | 74598fe7e9097484c4029e2731e462c6c82836f9 (patch) | |
tree | 3fed71a395b53b142bf9a0f35d6648cf9778418a /railties/lib | |
parent | 69f97f469747777ed1c457715f5361f6b8a0ab7b (diff) | |
download | rails-74598fe7e9097484c4029e2731e462c6c82836f9.tar.gz rails-74598fe7e9097484c4029e2731e462c6c82836f9.tar.bz2 rails-74598fe7e9097484c4029e2731e462c6c82836f9.zip |
Do not overwrite _railtie method on namespace while creating isolated engine or application.
In order to run Engine as standalone application, you will need
Rails::Application instance in the same namespace that engine
one. It's very important to leave _railtie bound to whatever
used "namespace" method first.
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/engine.rb | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 0620b8608e..ababf6a242 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -333,21 +333,22 @@ module Rails def namespace(mod) engine_name(generate_railtie_name(mod)) - _railtie = self name = engine_name - mod.singleton_class.instance_eval do - define_method(:_railtie) do - _railtie - end - - define_method(:table_name_prefix) do - "#{name}_" - end - end - self.routes.default_scope = {:module => name} - self.namespaced = true + + unless mod.respond_to?(:_railtie) + _railtie = self + mod.singleton_class.instance_eval do + define_method(:_railtie) do + _railtie + end + + define_method(:table_name_prefix) do + "#{name}_" + end + end + end end def namespaced? |