Forum: Ruby on Rails Active Scaffold controllers created dynamically at runtime?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
498cb397cceffccdf3a65b6516f3b681?d=identicon&s=25 Mike Laurence (Guest)
on 2007-06-27 03:55
Does anyone know how to link Rails' routes into anonymous controller
classes created at runtime (defined with their superclass as

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 :-)

Mike Laurence
588ab1c0a5610a7e160a3b101abb91e6?d=identicon&s=25 Michael Latta (Guest)
on 2007-06-27 05:08
(Received via mailing list)
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.

This topic is locked and can not be replied to.