I have a company model, and a company can have many locations, so I have routes set up like so:
resources :companies do
  resources :locations
end
I'd like to be able to add a new location to a company at the route companies/:company_id/locations/new , however this page is still accessible if I go to a company that does not exist, like so companies/99999999/locations/new. 
How can I make this page only accessible when the company id exists?
 
     
     
    