I have two same routes resources :errors with different url’s in different folders inside the routes.rb.
Routes:
---------
namespace :enr do
namespace :locations do #( url: enr/locations/:location_id/errors)
resources: errors
end
namespace :rds do
resources :errors #(url: enr/rds/errors)
end
end
controller:
------------
I have a controller for `enr/rds/errors` only.
how to change these two url’s by IF condition. For example,
if location_id is nil
i need to show this #(url: enr/rds/errors)
else
I need to show (url: enr/locations/:location_id/errors)
end
So it will change depends upon the location_id. Where should i write this condition to change the url’s by the location_id. Any Example would be more appreciated. Thanks
enr_locations_errorsandenr_lrds_errorsare not the only paths available. You can use one of the seven default routes (index,new,create,show,edit,update,destroy) or add a custom one. Checkrake routesand look here