Restrict Madmin routes using Devise/Rails authentication blocks
mainTo prevent non-admin users from even discovering the /madmin path, wrap your Madmin namespace in an authenticated block within config/routes.rb. Using authenticated is recommended over authenticate because it causes the route to return a 404 for unauthorized users, which helps hide the admin area from malicious attempts.
authenticated :user, lambda { |u| u.admin? } do
namespace :madmin do
end
end