Rails 3.0 / net-ldap - works in irb, but not in app
I've looked around and can't seem to find the answer to this... I'm trying to use net-ldap with rails.
in irb, I can run a quick bind and it works:
irb(main):003:0> ldap_con = Net::LDAP.new({:host => 'myhost.ad',
irb(main):004:2* :base => 'DC=myhost,DC=ad',
irb(main):005:2* :port => 389,:auth=>{:method=>:simple,:username => 'bsharpe@myhost.ad',
irb(main):006:3* :password => 'letmein' } } )
=> #<Net::LDAP:0x292089f0 @host="myhost.ad", @open_connection=nil, @encryption=nil, @auth={:password=>"letmein", :method=>:simple, :username=>"bsharpe@myhost.ad"}, @verbose=false, @por开发者_开发百科t=389, @base="DC=myhost,DC=ad">
irb(main):007:0> ldap_con.bind
=> true
but if i run the app i get
no such file to load -- net/ldap
which is from my require net/ldap
I checked $LOAD_PATH
and it does contain /usr/local/lib/ruby/gems/1.8/gems/net-ldap-0.1.1/lib
What am I missing here?
I had the same problem. Adding: require 'rubygems' before require 'net/ldap For example:
#!/usr/bin/ruby -w
require 'rubygems'
require 'net/ldap'
ruby version 1.8.7 and net/ldap(0.3.1)
精彩评论