I have a rails app with a route that is:
resources :users do
resources :api_keys
end
now I have the controllers and models and all tests are passing - but I would like a signed in user to go to their personal development centre, so I created:
resources :users do
resources :api_keys
resources :development_center
end
The issue is, that while here I would like the user to be able to access methods from the api_keys controller, that is: I would like the user to be able to view (show), create (create) and destroy (destroy) their api keys from the show action (and view) of the development_center controller.
In other words:
development_center show method should render the show view, which - for that user - SHOULD be able to create and view API's keys that user creates.
I would also like to stop you from navigating in the browser to site.com/users/id/api_keys/id - instead it should redirect you to development_center show method for that user.
I am new to the concept of nested routes and have been reading the documentation on routing But I am unclear how to:
- redirect when you attempt to visit any user/id/api_keys/ route
- call api_keys controller actions in development_center views to allow you to create and show and destroy your own api keys.