Nice patch. While we're on the topic, is the tangential issue of how view_paths can be made to work better in general. I had a patch ( http://dev.rubyonrails.org/ticket/8582) that preserved John Long's original semantics, but was rejected for aesthetic reasons. I tried contacting John to understand his use case, but haven't heard back (that was months ago).
The short explanation of the problem is that view_paths is dup'ed and frozen and passed into ActionView where it doesn't respect changes to the original ActionController.view_paths. Im using my patch in production along with my multisite plugin ( http://darwinweb.net/article/Announcing_Multisite_Plugin_For_Rails), but I need to rewrite it so it gets accepted. Since I can't get ahold of John Long, my plan is to get rid of the dup'ing and freezing and allow the original view_paths reference to be passed into ActionView so that it respects changes made through the controller. I don't see any good reason why the array should be dup'ed and frozen anyway, though the existing test suite ensures that. Since you are coming at this from a different angle (config.view_path and ActionMailer), I'd be interested in any feedback you have on this. On 8/15/07, Caio Chassot <[EMAIL PROTECTED]> wrote: > > > Hi all, > > I've been playing in the trunk with putting stuff in different dirs > to keep files from a reusable framework separate from the app files. > > > Here are a few considerations regarding the view_paths setting: > > config.view_path is used to set both action_controller.view_paths and > action_mailer.template_root. We get some buggy/unexpected behavior > here because action_controller.view_paths can be an array or a > string, while template_root is a single string. config.view_path can > be set to either a string or an array, as there's basically no type > checking, but that doesn't mean it'll work. > > So borkedness ensues. For example, when set to an array, you end up > with action_controller.view_paths being an array inside an array. > (See line 277 of initializer.rb) > > I can set config.action_controller.view_paths separately and then > results are saner, but the way config.view_path works now is a bit > confusing. > > My suggestion is that we change config.view_path to behave more like > config.controller_paths. First, it should be renamed to > config.view_paths. It should have a default value of ['app/views'], > so that one can add to it by pushing/unshifting. > > Next I suggest that for consistency, action_mailer deprecates its > template_root too, and get a view_paths just like action_controller. > > The whole view_paths thing seem scarcely tested. I already filed a > bug report with a patch at http://dev.rubyonrails.org/ticket/9258 > that fixes finding layouts. > > > I'd like to know from the core if my suggestions here are reasonable, > and if a patch to rework view_paths configuration in such way would > be welcome. > > > > > -- Gabe da Silveira http://darwinweb.net --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
