URL with "." which is part of a parameter, not an extension!

Hi, all!

Here's the problem! I have a page which is supposed to display the
profile of a member given it's username. For example:


Everything worked fine until some guy got the wonderfull idea to put a
"." in his username, and then, all I get is a 404 error, for rails takes
.hk as an extension!

Any idea how to make a route ignore "."'s ?

Thanks a lot!


You will have to code the names by yourself (and decode them when they
reach the controller); afar there is no way to do such ignorement.

Nauhaie None wrote:

You can restrict what the usernames can include in the model using


if you want to keep funky usernames, then use the wonderful
permalink_fu plugin to add a permalink attribute to your model. Then,
your map your routes to the permalink instead of the username. It'll
take you 10 minutes, and do all of the hard regular expression work
for you :wink:


You can use the regexp to accept “.” as a parameter.

The most simple way is:

map.connect ‘/users/:name’, :controller => ‘users’, :action => ‘xx’, :name => /.*/

sishen wrote:

map.connect '/users/:name', :controller => 'users', :action => 'xx',
=> /.*/

Impeccable! Thank you so much!