Mike Laurence
2007-Jun-27 01:55 UTC
Active Scaffold controllers created dynamically at runtime?
Does anyone know how to link Rails'' routes into anonymous controller classes created at runtime (defined with their superclass as ActionController::Base)? I''m trying to create a plugin for all of my projects that dynamically creates an active_scaffold controller for each model. It would essentially be like a scaffold_all_models for active_scaffold. I believe the original scaffold extensions mix in functionality to ActionController::Base, whereas active_scaffold (greedily) requires a separate controller for each model it scaffolds... hence my attempt to create dynamic controllers. PS: If anyone has already created a plugin like this, I would *gladly* just use yours :-) Thanks, Mike Laurence -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Latta
2007-Jun-27 03:08 UTC
Re: Active Scaffold controllers created dynamically at runtime?
I like the idea. Many of the controllers have no real value and are degenerate. The generated controllers could even implement the recommended security provisions to only expose the nested action. I was playing with routing for a different reason today, but it should not be that hard. The RouteSet looks at the path and extracts a set of parameter values from the environment, then asks each route in the set to match against the route. If it matches it extracts the parameter values from the path. Patching the extraction method to also generate a controller should be pretty straightforward. patch write_recognition to alias recognize and replace it with a wrapper method that also generates the controller. If that turns out to be a bit too late, do the same with recognition_extraction. Michael On Jun 26, 2007, at 6:55 PM, Mike Laurence wrote:> > Does anyone know how to link Rails'' routes into anonymous controller > classes created at runtime (defined with their superclass as > ActionController::Base)? > > I''m trying to create a plugin for all of my projects that dynamically > creates an active_scaffold controller for each model. It would > essentially be like a scaffold_all_models for active_scaffold. I > believe > the original scaffold extensions mix in functionality to > ActionController::Base, whereas active_scaffold (greedily) requires a > separate controller for each model it scaffolds... hence my attempt to > create dynamic controllers. > > PS: If anyone has already created a plugin like this, I would *gladly* > just use yours :-) > > Thanks, > Mike Laurence > > -- > Posted via http://www.ruby-forum.com/. > > --~--~---------~--~----~------------~-------~--~----~ > You received this message because you are subscribed to the Google > Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk- > unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > For more options, visit this group at http://groups.google.com/ > group/rubyonrails-talk?hl=en > -~----------~----~----~----~------~----~------~--~--- >
Maybe Matching Threads
- Active Scaffold Performance
- Rails routing and active scaffold fight to the death
- rails 2.3.2, active scaffold, nested, ActionView::TemplateError (undefined method `format_column' for #<ActionView::Base:
- Rails 2.3.x and active_scaffold Installation
- RSpec 1.1.3 + ZenTest 3.9.1 + Rails 1.2.6 do NOT ignore folders ^vendor/*