# Passing url withe period escape char

**URL:** <https://www.ruby-forum.com/t/passing-url-withe-period-escape-char/89394>\
**Category:** Rails\
**Created:** [March 20, 2007, 3:34am UTC](https://www.ruby-forum.com/t/passing-url-withe-period-escape-char/89394 "2007-03-20T03:34:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [March 20, 2007, 3:34am UTC](https://www.ruby-forum.com/t/passing-url-withe-period-escape-char/89394/1 "2007-03-20T03:34:59Z")

</div>

In my app I’m trying to use url’s like /foo/23/bar

Everything works, except if there’s a decimal. That is, I get a routing  
error if that 23 is a 23.5 or a 23.0. I saw a bug posted on escape  
chars and it looks like it should be fixed in Rails 1.2.3, but I’m  
still having issues. The patch, however, doesn’t explicitly show it  
working with the period, just other chars like ? @ [ etc…

[http://dev.rubyonrails.org/attachment/ticket/7544/routing.1.patch](http://dev.rubyonrails.org/attachment/ticket/7544/routing.1.patch)

Anyone have any insights on this? I’m pretty much stumped…

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [March 20, 2007, 3:44am UTC](https://www.ruby-forum.com/t/passing-url-withe-period-escape-char/89394/2 "2007-03-20T03:44:45Z")

</div>

Vince W. wrote:

> Anyone have any insights on this? I’m pretty much stumped…

map.connect ‘/foo/:param1/:param2’, :controller =\> “foo”, :requirements  
=\> { :param1 =\> /.\*/ }

–  
Michael W.

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [March 20, 2007, 3:54am UTC](https://www.ruby-forum.com/t/passing-url-withe-period-escape-char/89394/3 "2007-03-20T03:54:36Z")

</div>

Michael W. wrote:

> map.connect ‘/foo/:param1/:param2’, :controller =\> “foo”, :requirements  
> =\> { :param1 =\> /.\*/ }

That didn’t seem to work… not sure if it’s because I’m using restful  
routes. My actual routes snippet looks like this:

map.resources :locations, :controller =\> ‘home’, :action =\> “index”,  
:requirements =\> { :lat =\> /.\*/ },  
:member\_path =\> “/locations/:lat,:lng,:distance” do |location|  
location.resources :categories do |categories|  
categories.resources :places, :name\_prefix =\> ‘category\_’ do  
|places|  
places.resources :addresses  
end  
end

(I’m using the resource hacks plugin:  
[JvoorHis.com is for sale | HugeDomains](http://www.jvoorhis.com/articles/2006/08/01/announcing-resource_hacks))

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [March 20, 2007, 7:31am UTC](https://www.ruby-forum.com/t/passing-url-withe-period-escape-char/89394/4 "2007-03-20T07:31:45Z")

</div>

Michael W. wrote:

> You’ll get a warning about modifying a constant but it should work.

And it does! _Thank you_

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [March 20, 2007, 7:10am UTC](https://www.ruby-forum.com/t/passing-url-withe-period-escape-char/89394/5 "2007-03-20T07:10:11Z")

</div>

Vince W. wrote:

> map.resources :locations, :controller =\> ‘home’, :action =\> “index”,  
> (I’m using the resource hacks plugin:  
> [JvoorHis.com is for sale | HugeDomains](http://www.jvoorhis.com/articles/2006/08/01/announcing-resource_hacks))

Hmm…I haven’t worked in that sort of setup before. You could try  
overriding what special characters are used for routing if you don’t  
care about the routing by extension feature of Rails (e.g. route by  
.rss, .xml, etc.).

The actual source is in:

actionpack/lib/action\_controller/routing.rb

and the line that’s sets up the special characters is:

SEPARATORS = %w( / ; . , ? )

You can hack the source code directly or add something like this to your  
config/routes.rb file:

ActionController::Routing::SEPARATORS = %w( / ; , ? )

You’ll get a warning about modifying a constant but it should work.

–  
Michael W.
