Hi,
at the moment it is quite difficult to combine multiple Rails apps, e.g.
a forum and a wiki. Neither components nor engines provide a sufficient
level of separation between the parts of the applications to make this
considerably easier, because in the end almost everything becomes mixed
up in the same namespace.
A way to avoid this would be to create all the engine classes (models,
controllers, helpers) inside a module. This would open a whole number of
interesting possibilities:
Controllers/Routing
==================
Controller names of different applications do not collide, you can have
a BooksController both in a wiki and in a book database.
To connect an URL directly to the controller of an engine:
map.connect ''book/:id'', :module = "wiki_engine",
:controller =>
"books", :action => "show"
To delegate an URL to the routing of the engine:
map.connect ''wiki/:url'', :module = "wiki_engine"
...and the "url" part will be processed by the routes.rb of the
engine.
Modules
======
If you need to "talk" to a module of another engine you can write
WikiEngine::Book.find(xyz)
If you want the WikiEngine and the BooksEngine to use the same "User"
model:
WikiEngine::User = BooksEngine::User = MyUserModel
To prevent collision between table names you could assign a table prefix
to an engine or make it use a seperate database connection:
WikiEngine::table_prefix = ''wiki''
There might be problems I haven''t thought of, and changing Rails to
deal
with modules would probably be a lot of work. But on the other hand it
could be a more general solution for both components and engines in the
current form.
What do you think?
Andreas
--
Posted via http://www.ruby-forum.com/.