Dynamic controller dispatching in rails 3

Is there any offical way you could dynamically dispatch controllers in
Rails 3?
My goal is to invoke different controllers based on path segments like
this:

/news/sport-blog, should map to a blog controller
or
/news/sports/2, should map to a page controler

In the example cases above, the path should be queried from a STI page
model, and the type attribute should decide which controller to
invoke.

psuedo code:
match “*path_segments”, :to =>
“#{Page.find_by_path(params[:path_segments]).type}#index

The idea behind this is that it fits very nice in a cms system where
informative url:s are important. I’ve looked at other cms systems
built on Rails, many uses a single catch-all controller, but that
forces you to write another dispatcher on your own.

Thanks in advance
Fredrik Martenson

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