# Decode URL

**URL:** <https://www.ruby-forum.com/t/decode-url/74096>\
**Category:** Rails\
**Created:** [February 27, 2006, 11:18am UTC](https://www.ruby-forum.com/t/decode-url/74096 "2006-02-27T11:18:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JSSSSrg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3ec8ea/32.png) [@JSSSSrg](https://www.ruby-forum.com/u/JSSSSrg)\
**Post date:** [February 27, 2006, 11:18am UTC](https://www.ruby-forum.com/t/decode-url/74096/1 "2006-02-27T11:18:01Z")

</div>

Hi,

I have a URL with encoded characters, I want them to be decoded.  
Is this possible in the routes.rb?

e.g. decoding the @params[category]

map.connect ‘performances/:category’, :controller =\> ‘performance’,  
:action =\> ‘list\_performances’

regards,

Jörg

---

<div class="post-metadata">

**Author:** ![JSSSSrg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3ec8ea/32.png) [@JSSSSrg](https://www.ruby-forum.com/u/JSSSSrg)\
**Post date:** [February 27, 2006, 11:33am UTC](https://www.ruby-forum.com/t/decode-url/74096/2 "2006-02-27T11:33:13Z")

</div>

On Feb 27, 2006, at 3:17 AM, Jörg wrote:

> Hi,
> 
> I have a URL with encoded characters, I want them to be decoded.  
> Is this possible in the routes.rb?
> 
> e.g. decoding the @params[category]
> 
> map.connect ‘performances/:category’, :controller =\>  
> ‘performance’, :action =\> ‘list\_performances’

No, this is not possible. I think a before\_filter in the  
ApplicationController would be your best bet:

before\_filter :decode\_category

def decode\_category  
if params[:category]  
params[:category] = CGI.unescape(params[:category])  
end  
end

Duane J.  
(canadaduane)  
[http://blog.inquirylabs.com/](http://blog.inquirylabs.com/)
