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
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
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.