I have two text fields, first name and last name, that I would like to use as the permalink rather than the ID. How would I combine those two fields to become the permalink? I''ve come across tutorials on how to make one field become the permalink, but not two. I''m using Edge rails with REST routes. -- 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 -~----------~----~----~----~------~----~------~--~---
That''s pretty rough. Probably what I would do is in routes: map.namelink ''/people/names/:first_name/:last_name then in your controller you could do User.find_by_full_name(params[:first_name], params[:last_name]) And set up that method in your users model. Hope this helps! Jason Justin Ko wrote:> I have two text fields, first name and last name, that I would like to > use as the permalink rather than the ID. How would I combine those two > fields to become the permalink? I''ve come across tutorials on how to > make one field become the permalink, but not two. > I''m using Edge rails with REST routes. > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jason Norris wrote:> That''s pretty rough. > Probably what I would do is in routes: > > map.namelink ''/people/names/:first_name/:last_name > > then in your controller you could do > > User.find_by_full_name(params[:first_name], params[:last_name]) > > And set up that method in your users model. > Hope this helps! > JasonThanks for the suggestion! What I would really like is for the URL to be myapp.com/people/john_doe;edit Maybe a hidden text field (full_name) that get''s populated by combining first_name and last_name? I wonder if this is possible .... -- 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 -~----------~----~----~----~------~----~------~--~---
That was what I was thinking originally. It would still be OK, but you''ll have to split the name in your controller i.e. myapp.com/people/john_doe/edit then in PeopleController.rb I would do before_filter :split_name, :only => [''edit'', ''view'', etc...] protected def split_name @first_name, @last_name = params[:name].split("_") end Something like that should work. Then just use your first and last names to User.find Justin Ko wrote:> Jason Norris wrote: > >> That''s pretty rough. >> Probably what I would do is in routes: >> >> map.namelink ''/people/names/:first_name/:last_name >> >> then in your controller you could do >> >> User.find_by_full_name(params[:first_name], params[:last_name]) >> >> And set up that method in your users model. >> Hope this helps! >> Jason >> > > Thanks for the suggestion! What I would really like is for the URL to be > myapp.com/people/john_doe;edit > > Maybe a hidden text field (full_name) that get''s populated by combining > first_name and last_name? I wonder if this is possible .... > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thank you for your suggestion! Since I''m using REST routes I''d like to keep the controller as clean as possible so I''m going to go ahead and stick with integer urls. -- 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 -~----------~----~----~----~------~----~------~--~---