# Periods in parameter

**URL:** <https://www.ruby-forum.com/t/periods-in-parameter/165243>\
**Category:** Rails\
**Created:** [April 10, 2009, 5:54pm UTC](https://www.ruby-forum.com/t/periods-in-parameter/165243 "2009-04-10T17:54:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/bb73d2/32.png) [@ian](https://www.ruby-forum.com/u/ian)\
**Post date:** [April 10, 2009, 5:54pm UTC](https://www.ruby-forum.com/t/periods-in-parameter/165243/1 "2009-04-10T17:54:37Z")

</div>

I have a tag cloud going and a route defined like so:

map.connect ‘tags/:id’, :controller =\> “tag”, :action =\> “browse”

Works great, except when the phrase has a period in it (like “Web  
2.0”) Then I get a 404, presumably because Rails is interpreting that  
as a file name and an extension. I have wrapped CGI::escape around it  
but that doesn’t seem to affect periods. What’s the best way to  
handle this?

---

<div class="post-metadata">

**Author:** ![ian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/bb73d2/32.png) [@ian](https://www.ruby-forum.com/u/ian)\
**Post date:** [April 10, 2009, 6:20pm UTC](https://www.ruby-forum.com/t/periods-in-parameter/165243/2 "2009-04-10T18:20:25Z")

</div>

On Apr 10, 2009, at 8:53 AM, Ian wrote:

> I have a tag cloud going and a route defined like so:
> 
> map.connect ‘tags/:id’, :controller =\> “tag”, :action =\> “browse”
> 
> Works great, except when the phrase has a period in it (like “Web  
> 2.0”) Then I get a 404, presumably because Rails is interpreting that  
> as a file name and an extension. I have wrapped CGI::escape around it  
> but that doesn’t seem to affect periods. What’s the best way to  
> handle this?

I had a route where the :id could contain digits and/or a period.  
This worked for me.

:requirements =\> { :id =\> %r([-\d.]+) }

Tweak that to allow your other characters and you should be all  
right. However, in my case the full route was /foo/:id/:bar so maybe  
having it in the middle makes a difference.

Good luck!
