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. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On 8/15/07, Caio Chassot <lists@v2studio.com> 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.I, for one, agree with your suggestions. I''ve committed the patch, it looked good to me. Thanks. -- Rick Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
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 <lists@v2studio.com> 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 rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
I''m definitely in favour of this functionality, but from what I can tell, the test doesn''t pass. Your module''d controller is SubController, but nowhere in the view paths given is there a test/sub/hello_world.* template for it to render. The exact error I get is: Missing template test/sub.html.erb in view path ...which is a bit more worrying because it''s not even looking for hello_world.erb/rxml/rhtml/anything. Am I missing something here? On 8/15/07, Rick Olson <technoweenie@gmail.com> wrote:> > On 8/15/07, Caio Chassot <lists@v2studio.com> 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. > > I, for one, agree with your suggestions. I''ve committed the patch, it > looked good to me. Thanks. > > -- > Rick Olson > http://lighthouseapp.com > http://weblog.techno-weenie.net > http://mephistoblog.com > > > >-- * J * ~ --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On 2007-08-15, at 17:25 , James Adam wrote:> The exact error I get is: > > Missing template test/sub.html.erb in view path > > ...which is a bit more worrying because it''s not even looking for > hello_world.erb/rxml/rhtml/anything. > > Am I missing something here?You are. It explicitly calls render on ''test/hello_world'' and expclitily asks for the layout at ''test/sub''. The thing i''m testing for is that the test/sub layout is on a dir that''s not the first on view_paths. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On 8/16/07, Caio Chassot <lists@v2studio.com> wrote:> On 2007-08-15, at 17:25 , James Adam wrote: > You are. > > It explicitly calls render on ''test/hello_world'' and expclitily asks > for the layout at ''test/sub''. > > The thing i''m testing for is that the test/sub layout is on a dir > that''s not the first on view_paths. >True. It turns out that your patch didn''t contain the "sub" layout that you were asking for, but Rick has added this in Changeset 7322. I''ve re-fixed the ticket. -- * J * ~ --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---