问题
I have set up rails_Admin gem for my app. I want to redirect to a 404 page if the user is not an admin. Here is the code below -
RailsAdmin.config do |config|
config.authorize_with do |controller|
unless user_signed_in? && current_user.admin?
#redirect to 404 - I need the code for this!
end
end
end
How do I do it?
回答1:
You can just do:
raise ActionController::RoutingError.new('Not Found')
来源:https://stackoverflow.com/questions/23892782/rails-admin-redirect-to-404