aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2010-08-03 22:54:56 +0200
committerPiotr Sarnacki <drogus@gmail.com>2010-09-03 22:59:11 +0200
commit2e4e1e7d0ce9bd0e9ea116a05a4ffcd989541cbd (patch)
tree1518f690c4640bf2e08e7941a3412054da2ccbf6 /railties
parentdb8a864e693034b5a0d03396a0c297d5557862ed (diff)
downloadrails-2e4e1e7d0ce9bd0e9ea116a05a4ffcd989541cbd.tar.gz
rails-2e4e1e7d0ce9bd0e9ea116a05a4ffcd989541cbd.tar.bz2
rails-2e4e1e7d0ce9bd0e9ea116a05a4ffcd989541cbd.zip
Added documentation for namespaced Engine
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/engine.rb36
1 files changed, 34 insertions, 2 deletions
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb
index 663feb4e32..bf0d476e48 100644
--- a/railties/lib/rails/engine.rb
+++ b/railties/lib/rails/engine.rb
@@ -153,13 +153,45 @@ module Rails
# to application's public directory. To simplify generating paths for assets, you can set asset_path
# for an Engine:
#
- # class MyEngine::Engine < Rails::Engine
- # config.asset_path = "/my_engine/%s"
+ # module MyEngine
+ # class Engine < Rails::Engine
+ # config.asset_path = "/my_engine/%s"
+ # end
# end
#
# With such config, asset paths will be automatically modified inside Engine:
# image_path("foo.jpg") #=> "/my_engine/images/foo.jpg"
#
+ # == Namespaced Engine
+ #
+ # Normally, when you create controllers, helpers and models inside engine, they are treated
+ # as they would be created inside application. One of the cosequences of that is including
+ # application's helpers and url_helpers inside controller. Sometimes, especially when your
+ # engine provides its own routes, you don't want that. To isolate engine's stuff from application
+ # you can use namespace method:
+ #
+ # module MyEngine
+ # class Engine < Rails::Engine
+ # namespace MyEngine
+ # end
+ # end
+ #
+ # With such Engine, everything that is inside MyEngine module, will be isolated from application.
+ #
+ # Consider such controller:
+ #
+ # module MyEngine
+ # class FooController < ActionController::Base
+ # end
+ # end
+ #
+ # If engine is marked as namespaced, FooController has access only to helpers from engine and
+ # url_helpers from MyEngine::Engine.routes.
+ #
+ # Additionaly namespaced engine will set its name according to namespace, so in that case:
+ # MyEngine::Engine.engine_name #=> "my_engine"
+ # and it will set MyEngine.table_name_prefix to "my_engine_"
+ #
class Engine < Railtie
autoload :Configurable, "rails/engine/configurable"
autoload :Configuration, "rails/engine/configuration"