Hi engines developers, I'm working on a project that uses Cells extensively (http://nick.smt.de/trac/nick/wiki/Cells). Cells relies on Engines in turn. I hit a wall when I tried to make cells load a class tree of cells This was caused by the way Cells works, but I will not bother you with the boring details of that. I decided to rework the way cells loads its classes, and the best way to do this is via the autoload dependencies system, which is overridden by Engines. This requires that the correct file is loaded not only when the user refers to FooController (from controllers/foo_controller.rb), but also when the user refers to FooCell (from cells/foo_cell.rb). This can be done by copying over the entire require_or_load_with_engine_additions and adding 'cell' to the file_types, but that would be silly and very un-DRY. Instead, I propose this patch (see attachment). It adds a new mattr_accessor Engines.file_types which defaults to ['controller', 'helper']. Cells then adds to this so it reads ['controller', 'helper', 'cell'] and hacks the load paths in such a way that the correct load paths are looked up. In my opinion, this small patch paves the way for other cell-like extensions to Rails, so I would like to see this integrated in Engines. Comments? Suggestions? Regards, Peter Bex Solide ICT - http://www.solide-ict.nl
on 21.08.2007 14:52
on 21.08.2007 15:02
Hi Peter - This looks like a very reasonable patch. The only thing I might ask is that we think of a better name than "file_types", as "Engines.file_types" doesn't really nail which its values are being used for. My first thought was "Engines.file_types_to_mix", although I'm definitely open to suggestions. If you submit this as a patch to http://dev.rails-engines.org, it will get committed in the very near future. Thanks again! James
on 21.08.2007 15:23
On Tue, Aug 21, 2007 at 02:01:36PM +0100, James Adam wrote: > Hi Peter - > > This looks like a very reasonable patch. The only thing I might ask is > that we think of a better name than "file_types", as > "Engines.file_types" doesn't really nail which its values are being > used for. Agreed, this name was just something I came up with quickly to test if this approach would work. It should be more descriptive. > My first thought was "Engines.file_types_to_mix", although > I'm definitely open to suggestions. > > If you submit this as a patch to http://dev.rails-engines.org, it will > get committed in the very near future. I did, and I added a couple of suggestions for a more descriptive name to the ticket. Let's continue discussion there, if needed. Regards, Peter Bex Solide ICT - http://www.solide-ict.nl