# Dynamic Routing

**URL:** <https://www.ruby-forum.com/t/dynamic-routing/119838>\
**Category:** Rails\
**Created:** [November 11, 2007, 5:25am UTC](https://www.ruby-forum.com/t/dynamic-routing/119838 "2007-11-11T05:25:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_Swasey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f07891/32.png) [@Matthew\_Swasey](https://www.ruby-forum.com/u/Matthew_Swasey)\
**Post date:** [November 11, 2007, 5:25am UTC](https://www.ruby-forum.com/t/dynamic-routing/119838/1 "2007-11-11T05:25:05Z")

</div>

I need to do some dynamic routing in my application. It’s a CMS type-  
application, so it needs to allow for users to create their own pages.

Heres what I was doing before:

# config/routes.rb

map.connect “\*path”, :controller =\> “user\_pages”, :action =\> “show”

The show action would then take params[:path] and find the correct  
page. That was working great, until I had to enable the users to be  
able to create sub-pages on already existing controller routes. For  
example, I’ve got a:

map.resources :photos

in my routes config, which maps to a photos\_controller.rb with all the  
normal CRUD translated actions. However, the user is supposed to be  
able to create custom pages in the same /photos URL. For example:  
[example.com/photos/family](http://example.com/photos/family)

So I need something in the routes that tells rails to take a path  
like /photos and route it to the photos\_controller like normal, but to  
take a route like /photos/family and route it to the user\_pages  
controller.

I’ve been trying to use the :requirements parameter along with the  
\*pages in the routing but that is failing miserably. Anyone have any  
suggestions for me? Thanks for listening.
