0

I am using rails 2.3.5 .

I need to have a url format like

/:first_name{space}:last_name  # e.g.: /Michael Jackson

/:first_name{_}:last_name      # e.g.: /Michael_Jackson

Currently iam having this as the format which works

map.shorturl "/:first_name.:last_name", :controller => 'users', :action => 'show' ex: Michael.Jackson

The dot in between is working.. but the other two formats are not working.

Is it possible to have those formats? if yes, how?

Stuart M
  • 11,458
  • 6
  • 45
  • 59
ilayabasu
  • 66
  • 3
  • space MUST be encoded, as %20 or + [link](http://stackoverflow.com/questions/497908/are-urls-allowed-to-have-a-space-in-them) – trompa Apr 02 '13 at 07:43
  • I tried both the %20 or + both are not working. map.shorturl "/:first_name%20:last_name", :controller => 'deceased_users', :action => 'show' .. I tried the parenthesis also but no luck map.shorturl "/(:first_name)_(:last_name)", :controller => 'deceased_users', :action => 'show'. , but the . i working – ilayabasu Apr 03 '13 at 11:02

1 Answers1

0

For spaces i'm pretty sure you will have to encode to %20 or +. See link on comment.

For "_" you can enclose the parameters in parentheses to make rails treat each part as a different one another SO post.

Are you sure the dot separated form is working well? I'm not sure but i would bet that rails will try to use the second parameter as format

Community
  • 1
  • 1
trompa
  • 1,967
  • 1
  • 18
  • 26