I want to create a rails3 website with LDAP, so I chose the gem ruby-ldap (not net / ldap) that we used in our old rails2 applications and it works very well.
But I keep getting weird error in rails3 application, see codes below:
require 'ldap'
class WelcomeController < ApplicationController
def index
begin
@test = LDAP::Conn.new('10.72.64.11', 389)
rescue LDAP::Error
p LDAP::Error
end
render :text => "ok"
end
end
welcome # index is my root route. In most cases, the application crashes when switching to LDAP :: Conn.new ('10 .72.64.11 ', 389), even I tried to use "pry" for debugging and tracking, throwing
[1] 24797 trace trap rails s
and the WEBrick server will be terminated at this time.
Sometimes it throws a different type of error when I use "pry" for the step,
#<NameError: uninitialized constant WelcomeController::LDAP>
During playback in the console, everything is going well.
1.9.3-p194 :001 > require 'ldap'
=> true
1.9.3-p194 :002 > @test = LDAP::Conn.new('10.72.64.11', 389)
=> #<LDAP::Conn:0x00000101289568>
1.9.3-p194 :003 >
Can you steer me out of this crazy man? I am using ruby 1.9.3p194 and rails 3.2.8