Forum: Ruby on Rails decode URL

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jörg (Guest)
on 2006-02-27 12:18
(Received via mailing list)
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
Duane J. (Guest)
on 2006-02-27 12:33
(Received via mailing list)
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/
This topic is locked and can not be replied to.