Dynamic URL -> Controller mapping for routes in Rails
Posted
by Daniel Beardsley
on Stack Overflow
See other posts from Stack Overflow
or by Daniel Beardsley
Published on 2010-04-07T22:14:51Z
Indexed on
2010/04/08
2:23 UTC
Read the original article
Hit count: 406
I would like to be able to map URLs to Controllers dynamically based on information in my database.
I'm looking to do something functionally equivalent to this (assuming a View
model):
map.route '/:view_name',
:controller => lambda { View.find_by_name(params[:view_name]).controller }
Others have suggested dynamically rebuilding the routes, but this won't work for me as there may be thousands of Views that map to the same Controller
© Stack Overflow or respective owner