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

Thanks,
Mike L.

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs