On Miércoles, 27 de Mayo de 2009 12:35:01 Ed W escribió: > Sergio Cambra .:: entreCables S.L. ::. wrote: > > I think the best way it's to add an method, add_active_scaffold_path, > > to add view paths. All paths added by plugins usually should go > > between active_scaffold_overrides and active_scaffold_frontends, so it > > will be enough with that method most time. > > Whilst that works for me and my needs, it occurs to me that someone > might want to create a plugin which overrides some builtin AS > functionality. In that case it might be helpful to insert the paths > before the AS paths? Or perhaps some enterprising person wants to do > something equally clever and override the paths using a before filter or > whatever
Inserting paths between active_scaffold_overrides and active_scaffold_frontends you can override AS views. Usually the paths are like: active_scaffold_overrides = ['app/views/active_scaffold_overrides'] active_scaffold_frontends = ['vendor/plugins/active_scaffold/frontends/default/views'] Rewriting active_scaffold_paths, you can break ActiveScaffold, so you should only add paths to active_scaffold_overrides or prepend paths to active_scaffold_frontends. Adding paths to active_scaffold_frontends only is useful to add new views, but you can't override them. If you use some engines and another theme the paths will be: active_scaffold_overrides = ['app/views/active_scaffold_overrides', 'vendor/plugins/your_engine/app/views/active_scaffold_overrides'] active_scaffold_frontends = ['vendor/plugins/active_scaffold/frontends/your_frontend/views', 'vendor/plugins/active_scaffold/frontends/default/views'] So I have added a method to add paths between active_scaffold_overrides and active_scaffold_frontends. The best place to add paths for all plugins. add_active_scaffold_path 'new_path' > > Seems to me that if the code were changed as follows: > > > module ClassMethods > def active_scaffold(model_id = nil, &block) > > .. # define as paths > .. > @active_scaffold_paths ||= > ActionView::PathSet.new(@active_scaffold_overrides + > @active_scaffold_frontends) unless @active_scaffold_overrides.nil? || > @active_scaffold_frontends.nil? > .. > > end > > > def active_scaffold_paths > @active_scaffold_paths > end I prefer lazy generation of @active_scaffold_paths because you can add more paths after active_scaffold configuration. > > > def active_scaffold_paths=(new_path > @active_scaffold_paths = new_path > end > > > > Then this would be more flexible and suit all needs? > > Should also make it easier to be introspective about the paths currently > set if that were needed in some code. > > What do you think? I can't see why someone wants to remove default active_scaffold_paths. The usual way is adding new paths, after overrides, so you can override plugin views in each application, and before active_scaffold frontends paths, so plugins can override active_scaffold default views. -- Sergio Cambra .:: entreCables S.L. ::. Nicolás Guillén 6, locales 2 y 3. 50.018 Zaragoza T) 902 021 404 F) 976 52 98 07 E) [email protected] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en -~----------~----~----~----~------~----~------~--~---
