Reputation: 5314
I have 4 models :
A place can have many events. There's a many to many relationship between Event and User through Rsvp.
I want to get all events for a place and i want to get all events for a user.
So my routes look like this :
namespace :api do
namespace :v1 do
resources :users do
resources :events
end
resources :places do
resources :events
end
end
end
Now, if i call Get /users/1/events and Get /places/1/events i hit the EventsController#index.
My question is : how can i know which route is used to answer accordingly ?
Bonus question : am i on the right track or is there another way to do this ?
Thanks
Upvotes: 0
Views: 407
Reputation: 10406
One will have params[:user_id]
set and the other will have params[:place_id]
Upvotes: 1