# Funky routing

**URL:** <https://www.ruby-forum.com/t/funky-routing/96004>\
**Category:** Rails\
**Created:** [June 22, 2006, 7:49am UTC](https://www.ruby-forum.com/t/funky-routing/96004 "2006-06-22T07:49:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![guest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@guest](https://www.ruby-forum.com/u/guest)\
**Post date:** [June 22, 2006, 7:49am UTC](https://www.ruby-forum.com/t/funky-routing/96004/1 "2006-06-22T07:49:18Z")

</div>

map.connect ‘:controller/:action/:id’, :requirements =\> { :id =\>  
/^(.html)/ }

The requirement is turning all of my routes into /foo?id=54354 instead  
of /foo/54354

Why?

---

<div class="post-metadata">

**Author:** ![guest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@guest](https://www.ruby-forum.com/u/guest)\
**Post date:** [June 22, 2006, 7:53am UTC](https://www.ruby-forum.com/t/funky-routing/96004/2 "2006-06-22T07:53:43Z")

</div>

Guest wrote:

> map.connect ‘:controller/:action/:id’, :requirements =\> { :id =\>  
> /^(.html)/ }
> 
> The requirement is turning all of my routes into /foo?id=54354 instead  
> of /foo/54354
> 
> Why?

I can only ask that you ignore the regex dealing with .html because of  
the business requirements.

---

<div class="post-metadata">

**Author:** ![guest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@guest](https://www.ruby-forum.com/u/guest)\
**Post date:** [June 22, 2006, 8:02am UTC](https://www.ruby-forum.com/t/funky-routing/96004/3 "2006-06-22T08:02:07Z")

</div>

On Thu Jun 22, 2006 at 07:49:18AM +0200, Guest wrote:

> map.connect ‘:controller/:action/:id’, :requirements =\> { :id =\>  
> /^(.html)/ }
> 
> The requirement is turning all of my routes into /foo?id=54354 instead  
> of /foo/54354

ive noticed similar stuff. are you using SVN? i m prett sure some things  
subtly changed. but i need to do an SVN up and see if it goes awa, i  
havent updated for a few weeks. basically everything works fine on a  
production server with apache, but here, things are totally screwed, i  
get a lot of that ?id= crap…

---

<div class="post-metadata">

**Author:** ![guest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@guest](https://www.ruby-forum.com/u/guest)\
**Post date:** [June 22, 2006, 8:31am UTC](https://www.ruby-forum.com/t/funky-routing/96004/4 "2006-06-22T08:31:01Z")

</div>

I’m still running 1.1.2, so this shouldn’t be affected by what Jamis is  
working on.

---

<div class="post-metadata">

**Author:** ![guest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@guest](https://www.ruby-forum.com/u/guest)\
**Post date:** [June 22, 2006, 8:14am UTC](https://www.ruby-forum.com/t/funky-routing/96004/5 "2006-06-22T08:14:56Z")

</div>

routes are behaving much different (eg broken) for me lately (r4484).  
but maybe theres a better way to to short\_urls anyways. this is my wild  
guess, which worked fine with 1.1.2, but is unfortunately not  
consoldated to routes.rb:

_routes_\_  
map.entity ‘entity/:id’, :controller =\> ‘entity’, :action =\> ‘show’,  
:requirements =\> { :id=\> /\d+/ }  
map.entity ‘\*shorturl’,:controller =\> ‘entity’, :action =\> ‘show’

_helper_  
module EntityHelper  
def u(e)  
e.short\_url ? entity\_url(:shorturl =\> e.short\_url) : entity\_url(:id  
=\> e.id)  
end  
end

_ctrlr_  
@e = Entity.find(params[:id]) if params[:id]  
@e = Entity.find\_by\_short\_url(params[:shorturl]) if params[:shorturl]

in the meantime, ive gone back to the revision in use on the server…
