# CMS-like routing

**URL:** <https://www.ruby-forum.com/t/cms-like-routing/53790>\
**Category:** Rails\
**Created:** [February 14, 2006, 4:49pm UTC](https://www.ruby-forum.com/t/cms-like-routing/53790 "2006-02-14T16:49:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lakitu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@lakitu](https://www.ruby-forum.com/u/lakitu)\
**Post date:** [February 14, 2006, 4:49pm UTC](https://www.ruby-forum.com/t/cms-like-routing/53790/1 "2006-02-14T16:49:26Z")

</div>

I’d like to set up routes like //. Using a route like  
map.connect ‘:section/:article’ works just fine, but I’ve also got an  
admin area that is accessed through the route ‘admin’.

Inside the admin area I’ve got subpages like admin/sections and  
admin/articles. This is conflicting with the other routes and I’m not  
able to write something like map.connect ‘admin/:section’, :controller  
=\> ‘admin/:section’.

Any suggestions on this?

---

<div class="post-metadata">

**Author:** ![lakitu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@lakitu](https://www.ruby-forum.com/u/lakitu)\
**Post date:** [February 14, 2006, 5:22pm UTC](https://www.ruby-forum.com/t/cms-like-routing/53790/2 "2006-02-14T17:22:51Z")

</div>

Yep, I have my ‘cms’ like tool setup to do just that. The only way I  
got around it is kind of fugly, but it works.

Heres what I have for some map entries…

#map to make sure that all the controllers that need be accessed are  
able to, and not  
#treated as “pages” in the cms  
map.connect “:controller/:action/:id” , :requirements =\> {  
:controller =\> /admin|any|other|controllers|here/ }

map.page “:path/:page”, :controller =\> ‘page’, :action =\> ‘view’

Basically I have one controller (pages\_controller) that the  
users/viewers of the site access and controls the display of the  
pages. In your case it would be :sections/:articles but you get the  
point.

Also, the order is important! The normal map needs to be above your  
section/article map.

Hope this helps!  
-Nick

---

<div class="post-metadata">

**Author:** ![lakitu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@lakitu](https://www.ruby-forum.com/u/lakitu)\
**Post date:** [February 15, 2006, 9:31am UTC](https://www.ruby-forum.com/t/cms-like-routing/53790/3 "2006-02-15T09:31:16Z")

</div>

On 14.2.2006, at 17.49, Frank Wittmann wrote:

> Any suggestions on this?  
> If you put the admin route before the standard one, everything should  
> work just fine.

Routes are always matched in the order they appear in routes.rb.

//jarkko

–  
Jarkko L.

> **[jlaine.net](https://jlaine.net/)**
>
> Your freedom to carry a gun messes with my freedom to walk around without fear. Your freedom to “stand your ground” with force is at odds with my …

[http://odesign.fi](http://odesign.fi)
