I would love to be able to do this. The one sticking point that I've come across at the moment is the way that Rails' dependencies automatically creates modules for ApplicationController subclasses.
Continuing the WikiEngine example, intuitively you'd want to put your controllers underneath the WikiEngine module too. However, Rails automagically creates this module and throws a fit if it already exists. Typically within Engines/Plugins/Whatever we want to have some control over this module, for setting configuration options for example. There might be ways around this, I'll have to look a bit more closely at how we can create normal modules that work cooperatively with those generated by the dependencies system. - james On 12/31/05, Andreas <[EMAIL PROTECTED]> wrote: > 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 > Rails-core@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-core > _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core