# Route generation problems

**URL:** <https://discuss.rubyonrails.org/t/route-generation-problems/3786>\
**Category:** rubyonrails-talk\
**Created:** [October 30, 2006, 5:41pm UTC](https://discuss.rubyonrails.org/t/route-generation-problems/3786 "2006-10-30T17:41:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gustav\_Railist](https://avatars.discourse-cdn.com/v4/letter/g/d2c977/32.png) [@Gustav\_Railist](https://discuss.rubyonrails.org/u/Gustav_Railist)\
**Post date:** [October 30, 2006, 5:41pm UTC](https://discuss.rubyonrails.org/t/route-generation-problems/3786/1 "2006-10-30T17:41:37Z")

</div>

Charlie Hubbard wrote:

> Hi,
> 
> I have an outstanding problem with route generation. Right now if I generate a route with the following syntax.
> 
> url\_for( :controller =\> "foo", :action =\> "bar", :id =\> 4 )
> 
> I get
> 
> /foo/bar/4
> 
> I always get a URL without a trailing slash on the end. I want to add a trailing slash always after the ID parameter. I have generated HTML content that I want to always append to the root URL like above. And I keep getting bad URLS. I also have another problem when doing route generation where:
> 
> url\_for( :controller =\> "foo", :action =\> "bar", :id =\> 4, :page =\> 5 )
> 
> returns:
> 
> /foo/bar/4?page=5
> 
> Eventhough my route configuration is:
> 
> &nbsp;&nbsp;map.connect "foo/bar/:id/:page", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:controller =\> "Foo", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:action =\> "bar", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:requirements =\> { :id =\> /\d+/, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:page =\> /(\d+)|(\w+\.html)/ }
> 
> This rule is never used when generating routes, and it's really important because of the problem I showed above.
> 
> Any help please?
> 
> Charlie

Hey C,

I guess you already tried the following, but just in case:

&nbsp;&nbsp;map.connect "foo/bar/:id/:page", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:controller =\> "foo", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:action =\> "bar", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:requirements =\> { :id =\> /\d+/, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:page =\> /(\d+)|(\w+\.html)/ }

&nbsp;&nbsp;# I've never had explicit x.html &nbsp;&nbsp;# requests routed to rails though &nbsp;&nbsp;# so I've no idea if it'll work

&nbsp;&nbsp;map.connect ":controller/:action/:id/" &nbsp;&nbsp;map.connect ":controller/:action/:id"

&nbsp;&nbsp;# should solve the trailing slash issue

Gustav Paul gustav@rails.co.za
