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
<% if location_id.nil? %>
<%= link_to 'nil location_id', enr_locations_errors %>
<% else %>
<%= link_to 'not nil location_id', enr_rds_errors %>
<% end %>
enr_locations_errors
and enr_lrds_errors
are 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. Check rake routes
and look here