Rails_admin redirect to 404

风格不统一 提交于 2019-12-11 12:16:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!