# Routing issues with special characters

**URL:** <https://www.ruby-forum.com/t/routing-issues-with-special-characters/108175>\
**Category:** Rails\
**Created:** [June 29, 2007, 7:32pm UTC](https://www.ruby-forum.com/t/routing-issues-with-special-characters/108175 "2007-06-29T19:32:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Serengeti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e495f1/32.png) [@Serengeti](https://www.ruby-forum.com/u/Serengeti)\
**Post date:** [June 29, 2007, 7:32pm UTC](https://www.ruby-forum.com/t/routing-issues-with-special-characters/108175/1 "2007-06-29T19:32:56Z")

</div>

I am using acts\_as\_taggable according to the examples in the Rails  
Recipes book. Everything works fine except for cases where I want to  
use a tag with a dot (like .NET) or a slash (like COM/OLE).

The problem is not really with acts\_as\_taggable, but rather with  
routing.

I am using the suggested technique where I use urls like /kb/list/  
mytag to display all the entries tagged “mytag.”

Here is the console output showing what happens when I use urls with  
dots or slashes:

This works as expected:

> > rs.recognize\_path “/kb/list/mytag”  
> > =\> {:id=\>“mytag”, :action=\>“list”, :controller=\>“kb”}

But check these out:

> > rs.recognize\_path “/kb/list/.NET”  
> > =\> {:anything=\>[“kb”, “list”,  
> > “.NET”], :controller=\>“kb”, :action=\>“index”}

> > rs.recognize\_path “/kb/list/COM%2FOLE”  
> > =\> {:anything=\>[“kb”, “list”, “COM”,  
> > “OLE”], :controller=\>“kb”, :action=\>“index”  
> > }

Note that I replaced “/” with “%2F” because that’s what happens in the  
browser when it urlencodes the string “COM/OLE.”

I suppose I could re-write the “list” action to use numeric ids  
instead of tag names, but I would hate to lose that functionality.

Does anybody know how to get routing to work under these circumstances?

---

<div class="post-metadata">

**Author:** ![Serengeti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e495f1/32.png) [@Serengeti](https://www.ruby-forum.com/u/Serengeti)\
**Post date:** [June 29, 2007, 7:37pm UTC](https://www.ruby-forum.com/t/routing-issues-with-special-characters/108175/2 "2007-06-29T19:37:45Z")

</div>

Why don’t you use the permalink\_fu plugin? It converts all the special  
characters you described in a pretty url format. So instead of COM/OLE  
it would be com-ole, then you could easily find your inestances by doing  
Model.find\_by\_permalink(params[:permalink)

–

Serengeti wrote:

> I am using acts\_as\_taggable according to the examples in the Rails  
> Recipes book. Everything works fine except for cases where I want to  
> use a tag with a dot (like .NET) or a slash (like COM/OLE).
> 
> The problem is not really with acts\_as\_taggable, but rather with  
> routing.
> 
> I am using the suggested technique where I use urls like /kb/list/  
> mytag to display all the entries tagged “mytag.”
> 
> Here is the console output showing what happens when I use urls with  
> dots or slashes:
> 
> This works as expected:
> 
> > > rs.recognize\_path “/kb/list/mytag”  
> > > =\> {:id=\>“mytag”, :action=\>“list”, :controller=\>“kb”}
> 
> But check these out:
> 
> > > rs.recognize\_path “/kb/list/.NET”  
> > > =\> {:anything=\>[“kb”, “list”,  
> > > “.NET”], :controller=\>“kb”, :action=\>“index”}
> 
> > > rs.recognize\_path “/kb/list/COM%2FOLE”  
> > > =\> {:anything=\>[“kb”, “list”, “COM”,  
> > > “OLE”], :controller=\>“kb”, :action=\>“index”  
> > > }
> 
> Note that I replaced “/” with “%2F” because that’s what happens in the  
> browser when it urlencodes the string “COM/OLE.”
> 
> I suppose I could re-write the “list” action to use numeric ids  
> instead of tag names, but I would hate to lose that functionality.
> 
> Does anybody know how to get routing to work under these circumstances?

---

<div class="post-metadata">

**Author:** ![Serengeti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e495f1/32.png) [@Serengeti](https://www.ruby-forum.com/u/Serengeti)\
**Post date:** [June 29, 2007, 7:43pm UTC](https://www.ruby-forum.com/t/routing-issues-with-special-characters/108175/3 "2007-06-29T19:43:57Z")

</div>

Thanks for the tip! I’ll give that a try.

---

<div class="post-metadata">

**Author:** ![Serengeti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e495f1/32.png) [@Serengeti](https://www.ruby-forum.com/u/Serengeti)\
**Post date:** [June 29, 2007, 9:18pm UTC](https://www.ruby-forum.com/t/routing-issues-with-special-characters/108175/4 "2007-06-29T21:18:12Z")

</div>

I’m a little stuck. Maybe you can help.

I am adding:

has\_permalink :name

to the class definition for Tag.

When I do this I get an error:

C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1  
.15.3/lib/active\_record/base.rb:1235:in  
`method_missing':NoMethodError: undefine d method`has\_permalink’ for Tag:Class

I assume this means that the acts\_as\_taggable plugin is trying to load  
its models before permalink\_fu has been loaded.

I have tried adding:

require ‘permalink\_fu’ to tag.rb, but that returns file not found  
errors. I have tried a few different ways of specifying the path to  
the permalink\_fu plugin but none work.

Is there another way to accomplish this?
