I am a new to rails so this is probably a basic question. I have a resource route as such: resources :user_profiles In one of my controllers, I have the following: redirect_to user_profiles_path(4) This redirects to the "show" action in the "user_profiles" controller, but the url structure is: http:/mydomain/user_profiles.4 Why is the url .4 and not /4? Any help would be appreciated! -- 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.
Robert Preville
2011-Sep-16 18:32 UTC
RE: Help with default resource routes using id arguments
Anyone have any ideas? -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of ERB Sent: Thursday, September 15, 2011 4:39 PM To: Ruby on Rails: Talk Subject: [Rails] Help with default resource routes using id arguments I am a new to rails so this is probably a basic question. I have a resource route as such: resources :user_profiles In one of my controllers, I have the following: redirect_to user_profiles_path(4) This redirects to the "show" action in the "user_profiles" controller, but the url structure is: http:/mydomain/user_profiles.4 Why is the url .4 and not /4? Any help would be appreciated! -- 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. -- 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.
Tim Shaffer
2011-Sep-16 18:37 UTC
Re: Help with default resource routes using id arguments
If you want to redirect to a specific user_profile, you probably want to use the singular helper: user_profile_path(4) The singular path accepts 2 arguments: id and format The plural helper (user_profiles_path) is for the "index" action and only accepts 1 argument: format Run rake:routes to take a look at the available URLs and their helpers. -- 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/-/830A3OTCjm8J. 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.
Robert Preville
2011-Sep-16 19:20 UTC
RE: Help with default resource routes using id arguments
Thanks Tim! That did the trick! From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Tim Shaffer Sent: Friday, September 16, 2011 2:38 PM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: Re: [Rails] Help with default resource routes using id arguments If you want to redirect to a specific user_profile, you probably want to use the singular helper: user_profile_path(4) The singular path accepts 2 arguments: id and format The plural helper (user_profiles_path) is for the "index" action and only accepts 1 argument: format Run rake:routes to take a look at the available URLs and their helpers. -- 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/-/830A3OTCjm8J. 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. -- 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.