Bob Sanders
2007-Jul-19 22:51 UTC
Transform URLs from: "url.com/Bob+Doe" to "url.com/bob_doe"
Is that possible, and would you know how I can do that? I''m creating individual pages for users based on their first and last names. In my routes.rb, I have: map.client '':user_full_name'', :controller => ''user'', :action => ''individual_user_page'' Then in my controller, I have: def individual_user_page @user = User.find(:first, :conditions => [''first_name = ?'', params[:user_full_name]]) render :layout => "user_page" end Right now, the url is in this format: "url.com/Bob+Doe" -- and I''m looking to get it in this format: "url.com/bob_doe" I googled for some time, and still have no idea where to start. Any help would be great appreciated. Thank you. -- 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 -~----------~----~----~----~------~----~------~--~---
schof
2007-Jul-20 00:38 UTC
Re: Transform URLs from: "url.com/Bob+Doe" to "url.com/bob_doe"
If you are using Apache HTTP Server they have some nice URL rewrite stuff. Of course you will still need to tell rails what controller you want. I''m new to Rails though so maybe there is a Rails specific way to do this. My personal bias is towards letting Apache take care of any massive amount of URL rewriting. On Jul 19, 6:51 pm, Bob Sanders <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Is that possible, and would you know how I can do that? > > I''m creating individual pages for users based on their first and last > names. > > In my routes.rb, I have: > > map.client '':user_full_name'', :controller => ''user'', :action => > ''individual_user_page'' > > Then in my controller, I have: > > def individual_user_page > @user = User.find(:first, :conditions => [''first_name = ?'', > params[:user_full_name]]) > render :layout => "user_page" > end > > Right now, the url is in this format: "url.com/Bob+Doe" -- and I''m > looking to get it in this format: "url.com/bob_doe" > > I googled for some time, and still have no idea where to start. Any help > would be great appreciated. Thank you. > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Richard Hancock
2007-Jul-20 15:08 UTC
Re: Transform URLs from: "url.com/Bob+Doe" to "url.com/bob_doe"
This got me to for a while. The method you are looking for is <dot>underscore. It takes a string as a parameter and out puts it like you want it. After that, you can parse how you need to search in the database. HTH, Richard On 7/19/07, schof <sean.schofield-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > If you are using Apache HTTP Server they have some nice URL rewrite > stuff. Of course you will still need to tell rails what controller > you want. I''m new to Rails though so maybe there is a Rails specific > way to do this. My personal bias is towards letting Apache take care > of any massive amount of URL rewriting. > > On Jul 19, 6:51 pm, Bob Sanders <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > Is that possible, and would you know how I can do that? > > > > I''m creating individual pages for users based on their first and last > > names. > > > > In my routes.rb, I have: > > > > map.client '':user_full_name'', :controller => ''user'', :action => > > ''individual_user_page'' > > > > Then in my controller, I have: > > > > def individual_user_page > > @user = User.find(:first, :conditions => [''first_name = ?'', > > params[:user_full_name]]) > > render :layout => "user_page" > > end > > > > Right now, the url is in this format: "url.com/Bob+Doe" -- and I''m > > looking to get it in this format: "url.com/bob_doe" > > > > I googled for some time, and still have no idea where to start. Any help > > would be great appreciated. Thank you. > > > > -- > > Posted viahttp://www.ruby-forum.com/. > > > > >-- Richard J Hancock Developer/System Administrator --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---