# Routing Issue

**URL:** <https://www.ruby-forum.com/t/routing-issue/86269>\
**Category:** Rails\
**Created:** [March 23, 2006, 8:52pm UTC](https://www.ruby-forum.com/t/routing-issue/86269 "2006-03-23T20:52:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vagabond](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@vagabond](https://www.ruby-forum.com/u/vagabond)\
**Post date:** [March 23, 2006, 8:52pm UTC](https://www.ruby-forum.com/t/routing-issue/86269/1 "2006-03-23T20:52:33Z")

</div>

Hi,

I have these entries in my routes.rb file:

map.connect ‘:id’,  
:controller =\> ‘wiki’,  
:action =\> ‘show’,  
:id =\> /^([A-Z]\w\*)+$/

map.connect ‘:controller/:action/:id’

map.connect ‘’,  
:controller =\> ‘wiki’,  
:action =\> ‘show’,  
:id =\> ‘HomePage’

I only want Rails to use the first route if :id is a camel-case word.  
But for some reason, this route catches even when there is no :id  
specified in the URL. So, the first route catches when the URL is  
something like [http://www.example.com/](http://www.example.com/), and I receive an error, because  
no :id parameter is specified in this case.

I would think that the regex in the first route would prevent this,  
since:

irb(main):005:0\> nil =~ /^([A-Z]\w\*)+$/  
=\> false  
irb(main):006:0\> ‘’ =~ /^([A-Z]\w\*)+$/  
=\> nil  
irb(main):007:0\> ‘TestPage’ =~ /^([A-Z]\w\*)+$/  
=\> 0

I must be missing something here, but I am not really sure what. If  
anywould could offer any information about this, I would greatly  
appreciate it.

Thanks,  
Andrew

---

<div class="post-metadata">

**Author:** ![vagabond](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@vagabond](https://www.ruby-forum.com/u/vagabond)\
**Post date:** [March 23, 2006, 9:26pm UTC](https://www.ruby-forum.com/t/routing-issue/86269/2 "2006-03-23T21:26:07Z")

</div>

Hi !

2006/3/23, Andrew T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> ```
> :id => 'HomePage'
> 
> ```

Move the last entry to the top of the file. Routes are evaluated in  
order, and the first one that matches is the one that will be used.

Hope that helps !

---

<div class="post-metadata">

**Author:** ![vagabond](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@vagabond](https://www.ruby-forum.com/u/vagabond)\
**Post date:** [April 7, 2009, 6:27am UTC](https://www.ruby-forum.com/t/routing-issue/86269/3 "2009-04-07T06:27:36Z")

</div>

Additionaly: when I use browse\_path(nil) it renders out just fine…

---

<div class="post-metadata">

**Author:** ![vagabond](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@vagabond](https://www.ruby-forum.com/u/vagabond)\
**Post date:** [April 7, 2009, 6:52am UTC](https://www.ruby-forum.com/t/routing-issue/86269/4 "2009-04-07T06:52:46Z")

</div>

On Mon, Apr 6, 2009 at 11:24 PM, Stijnster [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Additionaly: when I use browse\_path(nil) it renders out just fine…

Trying turning off routing optimisations in environment.rb:

config.action\_controller…optimise\_named\_routes = false

> > When I call the “browse\_path” in rails 2.3 it renders;

–  
Cheers

Koz
