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:

http://www.***.com/users/ahmed.hk

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!

Nauhaie

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
validates_format_of

OR

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:

Sudara

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',
:name
=> /.*/

Impeccable! Thank you so much!

Nauhaie