📜  rails rails admin 安全页面 - Ruby 代码示例

📅  最后修改于: 2022-03-11 15:04:45.735000             🧑  作者: Mango

代码示例1
config.authorize_with do |controller|
  if current_user.nil?
    redirect_to main_app.new_account_session_path, flash: {error: 'Please Login to Continue..'}
  elsif !current_user.admin?
    redirect_to main_app.root_path, flash: {error: 'You are not Admin bro!'}
  end
end