I have two questions on routing if any one has some spare time. 1. Is there any way to declare a resource and have its routes use something other than :id? so that it ends up that /users/:user_name maps to the show action 2. I noticed when I define a custom rout like match ''/passwords/:user_name/edit'' I don''t get any named paths that show up when I run rake routes Is there any way to say something like match ''/passwords/:user_name/edit'', :name => :change_password so that I can use it like link_to change_password_path @user Thank you every one hope all is well -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thursday, July 21, 2011 3:49:39 PM UTC-6, Ruby-Forum.com User wrote:> > I have two questions on routing if any one has some spare time. > > 1. Is there any way to declare a resource and have its routes use > something other than :id? so that it ends up that /users/:user_name maps > to the show action >Not that I know of (certainly not mentioned in the Guides or docs.> 2. I noticed when I define a custom rout like > > match ''/passwords/:user_name/edit'' > > I don''t get any named paths that show up when I run rake routes > > Is there any way to say something like > > match ''/passwords/:user_name/edit'', :name => :change_password >Yes, just use :as instead of :name match ''/passwords/:user_name/edit'' => ''password#edit'', :as => :change_password This gives you: rake routes change_password /passwords/:user_name/edit(.:format) {:controller=>"password", :action=>"edit"} Then you can use: change_password_path(@user) # assuming @user.user_name exists -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/QoraBz4pW_4J. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.