I have the following routing rules that would catch the HTTP status for some 'errors' and redirect the user to the error page:
%w[403 404 422 500 503].each do |code|
match code, to: 'errors#show', code: code, via: :all
end
I also have the root namespace and another one for 'admin'. I'd like to make this same route matching work for the admin namespace, so I added the same routing rules to it:
namespace :admin do
%w[403 404 422 500 503].each do |code|
match code, to: 'errors#show', code: code, via: :all
end
end
PROBLEM : It doesn't work and all the 403 requests are being redirected to /403 instead of /admin/403. Is there a way to achieve this goal?
I want to do it like this because I need to use different layouts for the error pages to show them with the application layout and also with the admin layout.