Nauhaie None
2008-Jan-18 13:58 UTC
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Damaris Fuentes
2008-Jan-18 14:33 UTC
Re: URL with "." which is part of a parameter, not an extension!
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:> 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-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
sudara
2008-Jan-18 14:45 UTC
Re: URL with "." which is part of a parameter, not an extension!
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 ;) Sudara On Jan 18, 3:33 pm, Damaris Fuentes <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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: > > 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 > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
sishen
2008-Jan-19 02:36 UTC
Re: URL with "." which is part of a parameter, not an extension!
You can use the regexp to accept "." as a parameter. The most simple way is: map.connect ''/users/:name'', :controller => ''users'', :action => ''xx'', :name => /.*/ On Jan 18, 2008 9:58 PM, Nauhaie None <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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 > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Nauhaie None
2008-Jan-19 14:35 UTC
Re: URL with "." which is part of a parameter, not an extens
sishen wrote:> > map.connect ''/users/:name'', :controller => ''users'', :action => ''xx'', > :name > => /.*/Impeccable! Thank you so much! Nauhaie -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---