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 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.
Routing a path directly to the controller of an engine could look like this:
map.connect 'book/:id', :module = "wiki_engine", :controller =>
"books", :action => "show"
To delegate a path to the routing of the engine:
map.connect 'wiki/:path', :module = "wiki_engine"
...and the "path" part will be processed by the routes.rb of the engine.
Models
======
If you need to "talk" to a model of another engine you could 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.
I would really like to hear the core developers' opinion on that.
Andreas
_______________________________________________
Rails-core mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-core