Ruby on rails Net::LDAP::连接中/users/sign_处的错误超时-用户指定的超时

Ruby on rails Net::LDAP::连接中/users/sign_处的错误超时-用户指定的超时,ruby-on-rails,devise,ldap,Ruby On Rails,Devise,Ldap,我正在使用designe_ldap_身份验证gem设置登录。有时LDAP服务器关闭,我会收到以下错误 “Net::LDAP::在/users/sign_处出错” 连接超时-用户指定的超时” 我尝试了多种方法来处理引发的错误,但我做不到 操作控制器: class SessionsController < Devise::SessionsController def create begin resource = warden.authenticate!(:scope

我正在使用designe_ldap_身份验证gem设置登录。有时LDAP服务器关闭,我会收到以下错误 “Net::LDAP::在/users/sign_处出错” 连接超时-用户指定的超时”

我尝试了多种方法来处理引发的错误,但我做不到

操作控制器:

class SessionsController < Devise::SessionsController
  def create
    begin
      resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
      set_flash_message(:notice, :signed_in) if is_navigational_format?
      sign_in(resource_name, resource)
      redirect_to root_path
    rescue Net::LDAP::LdapError
      respond_to do |format|
        format.html {redirect_to new_user_session_path, :notice => $!.to_s}
        format.json {render json: $!.to_s}
      end
    end
  end
end
class sessioncontrollerresource_name,:recall=>“#{controller_path}#new”)
如果是导航格式,则设置闪光消息(:注意,:登录)?
登录(资源名称、资源)
将\重定向到根\路径
救援网::LDAP::LdapError
回应待办事项|格式|
format.html{redirect_to new_user_session_path,:notice=>$!.to_s}
format.json{将json:$!.to_}
结束
结束
结束
结束
我想检查连接服务器,如果无法工作,请使用本地凭据验证用户