# Routes and permalinks problem

**URL:** <https://www.ruby-forum.com/t/routes-and-permalinks-problem/182256>\
**Category:** Rails\
**Created:** [January 25, 2010, 6:09pm UTC](https://www.ruby-forum.com/t/routes-and-permalinks-problem/182256 "2010-01-25T18:09:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cswebgrl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/edb3f5/32.png) [@cswebgrl](https://www.ruby-forum.com/u/cswebgrl)\
**Post date:** [January 25, 2010, 6:09pm UTC](https://www.ruby-forum.com/t/routes-and-permalinks-problem/182256/1 "2010-01-25T18:09:21Z")

</div>

Hi.

I’ve got a user who wants url’s to look like this:  
[www.domain.com/firstname-lastname](http://www.domain.com/firstname-lastname).

Right now I have a route set up like this  
map.user ‘:user’, :controller =\> ‘user’, :action =\> ‘show’

This causes problems when I get robots and people searching for urls  
that don’t map to an existing user. So I want to put in something that  
will catch the 404’s, log them in a database and route the searcher to  
an appropriate page.

Is this something where I should change the route code or put in a  
redirect inside of my user controller if the user is not found?

Any help on either how to do either of these 2 or other options would be  
greatly appreciated.

As a note, I am following the Adv Rails Recipes 404 code, but it’s not  
quite working based on my current needs.

THANKS!

---

<div class="post-metadata">

**Author:** ![cswebgrl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/edb3f5/32.png) [@cswebgrl](https://www.ruby-forum.com/u/cswebgrl)\
**Post date:** [January 25, 2010, 6:26pm UTC](https://www.ruby-forum.com/t/routes-and-permalinks-problem/182256/2 "2010-01-25T18:26:20Z")

</div>

The book shows to do a catch-all route at the bottom of the route  
file. map.connect ‘\*path’, :controller =\> ‘foo’. The \*path will put  
the values in an array ‘path’.

---

<div class="post-metadata">

**Author:** ![cswebgrl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/edb3f5/32.png) [@cswebgrl](https://www.ruby-forum.com/u/cswebgrl)\
**Post date:** [January 25, 2010, 7:52pm UTC](https://www.ruby-forum.com/t/routes-and-permalinks-problem/182256/3 "2010-01-25T19:52:47Z")

</div>

Yep, I’ve got that in my routes file. The problem is that the map.user  
picks up the url first and so it gets processed by that controller.

This is why I’m wondering what I need to change to get it all working  
together.
