Right now I'm making a website and I need to implement this functionality a user type Client belongs to a Company, so when it logs in, the Client should see a view regarding that company, I'm not sure how to handle this because he should see the company route ID, right now for example if the user is an Admin type I created a Namespace for it but that's because every admin can see the same info, the Client type should only see the company where he belongs, I'm not sure what should I be using, right now my route for that is defined like this
resources :companies, param: :slug, only: :show do
resources :clients
end
That works but for example if the Client belongs to the company amazon and he logs in, he's redirected to companies/amazon/clients, and it displays the proper info but if he changes the route for another for example companies/adaddasdas/clients, it stills shows the page as well with the amazon info, that just happens if I'm trying to access the resources inside companies like :clients in this example, if I try to access the resource companies itself companies/amazon if i put something different it does not work
What I want to know is how do you guys handle that, when an user model belongs to another but given the Id(in my case slug) of the other model, the user should be able to see just the info of that Id and as well se other resources for that Model. Should I use that or a namespace, or custom layout, I'm not sure how to solve it and there's no documentation regarding that topic.