Hi everyone, I have a nested resource that is generating the route: /events/id/ registrations.json However, I would like to know if I can do something like this: /events/ registrations.json With that said I have three questions: 1) If I can do that, would the events id still be passed and give me access to the proper registrations related to the event? 2) How does this look in my routes file? 3) Would there need to be a change in my controllers? You may find the code I am working with at: github.com/TheCodeBoutique/ Nested-Resource-Demo Kind Regards, Chad Eubanks The Code Boutique -- 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 10 May 2011, at 20:50, Banks <chadcreation-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi everyone, > > I have a nested resource that is generating the route: /events/id/ > registrations.json > > However, I would like to know if I can do something like this: /events/ > registrations.json > > With that said I have three questions: > 1) If I can do that, would the events id still be passed and give me > access to the proper registrations related to the event?Well the event id has to be somewhere, if not in the path then as a query param or in post data - you can''t get rid of it completely if you need to know which event''s registrations should be fetched Fred> 2) How does this look in my routes file? > 3) Would there need to be a change in my controllers? > > You may find the code I am working with at: github.com/TheCodeBoutique/ > Nested-Resource-Demo > > > Kind Regards, > Chad Eubanks > The Code Boutique > > -- > 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.
Fred, I understand I can not get rid of it completely. The reason I am asking this is this: I have a client side app that sets a proxy to the URL path with an extension .json. The events id is not a constant integer and therefore I can not set the proxy URL to an explicit events id. I need to have a constant URL path of events/registrations.json. From what you are saying. It sounds like it can be done but can you elaborate for me please. .... This might be a better example: users/id/posts.json. When user one logs in the related posts are shown. When user two logs in the related posts are shown. However, the id can not be shown in the url. Kind Regards, Chad Eubanks Sent from my iPhone On May 10, 2011, at 11:54 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 10 May 2011, at 20:50, Banks <chadcreation-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Hi everyone, >> >> I have a nested resource that is generating the route: /events/id/ >> registrations.json >> >> However, I would like to know if I can do something like this: /events/ >> registrations.json >> >> With that said I have three questions: >> 1) If I can do that, would the events id still be passed and give me >> access to the proper registrations related to the event? > > Well the event id has to be somewhere, if not in the path then as a query param or in post data - you can''t get rid of it completely if you need to know which event''s registrations should be fetched > > Fred >> 2) How does this look in my routes file? >> 3) Would there need to be a change in my controllers? >> >> You may find the code I am working with at: github.com/TheCodeBoutique/ >> Nested-Resource-Demo >> >> >> Kind Regards, >> Chad Eubanks >> The Code Boutique >> >> -- >> 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. >-- 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 May 11, 2011, at 11:00 AM, Chad Eubanks (gMail) wrote:> .... This might be a better example: users/id/posts.json. When user > one logs in the related posts are shown. When user two logs in the > related posts are shown. However, the id can not be shown in the url.The ID has to be somewhere. So you could be getting it from the session, right? Walter -- 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.
Very true... The session controller would do such. But the question still lingers, does the id NEED to be in the url? Kind Regards, Chad Eubanks Sent from my iPhone On May 11, 2011, at 9:20 AM, Walter Davis <waltd-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:> > On May 11, 2011, at 11:00 AM, Chad Eubanks (gMail) wrote: > >> .... This might be a better example: users/id/posts.json. When user one logs in the related posts are shown. When user two logs in the related posts are shown. However, the id can not be shown in the url. > > > The ID has to be somewhere. So you could be getting it from the session, right? > > Walter > > -- > 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.
Not if you''re grabbing it from somewhere. The ID MUST be somewhere, or the find will fail. @user = current_user if you''re using any sort of common authentication framework. From there, @user.posts is a drop-kick away. Walter On May 11, 2011, at 12:28 PM, Chad Eubanks (gMail) wrote:> Very true... The session controller would do such. But the question > still lingers, does the id NEED to be in the url? > > Kind Regards, > Chad Eubanks > > Sent from my iPhone > > On May 11, 2011, at 9:20 AM, Walter Davis <waltd-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote: > >> >> On May 11, 2011, at 11:00 AM, Chad Eubanks (gMail) wrote: >> >>> .... This might be a better example: users/id/posts.json. When >>> user one logs in the related posts are shown. When user two logs >>> in the related posts are shown. However, the id can not be shown >>> in the url. >> >> >> The ID has to be somewhere. So you could be getting it from the >> session, right? >> >> Walter >> >> -- >> 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 >> . >> > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@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.