Hi all,
I was hoping someone could please clarify the differences between a
full engine and a mountable one.
I have noticed the following:
** Full Engine **
- With a full engine, the parent application inherits the routes from
the engine. It is not necessary to specify anything in parent_app/
config/routes.rb. Specifying the gem in Gemfile is enough. The
engine routes are specified as:
my_engine/config/routes.rb
Rails.application.routes.draw do
whatever
end
- No namespacing of models, controllers, etc. These are immediately
accessible to the parent application.
** Mountable Engine **
- The engine’s namespace is isolated by default.
my_engine/lib/my_engine/engine.rb
module MyEngine
class Engine < Rails::Engine
isolate_namespace MyEngine
end
end
- With a mountable engine, the routes are namespaced and the parent
app can bundle this functionality under a single route:
my_engine/config/routes.rb
MyEngine::Engine.routes.draw do
#whatever
end
parent_app/config/routes.rb
Rails.application.routes.draw do
mount MyEngine::Engine => “/engine”, :as => “namespaced”
end
- Models, controllers, etc are isolated from the parent application -
although helpers can be shared easily.
Is this correct and are these the main differences? Are there any
other differences between a full and mountable engine that I missed?
Thanks,
Adam