Use net/ldap from my controller

I downloaded net-ldap gem and had no problem to use it from non-rail
applications.

But when I require ‘net/ldap’ from inside a rails controller. Rails
complains that it cannot load

LoadError (no such file to load – net/ldap):
app/controllers/supplier_controller.rb:1

I tried to add the following to my environment.rb:
Rails::Initializer.run do |config|
config.gem :net-ldap
end

but now rails complains:

C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.1/lib/rails/application.rb:63:in
inherited': You cannot have more than one Rails::Application (RuntimeError) from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.1/lib/rails/deprecation.rb:7:ininitialize’
from
C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.1/lib/rails/deprecation.rb:7:in
new' from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.1/lib/rails/deprecation.rb:7:inrun’

On Tue, Oct 26, 2010 at 6:33 AM, Peter P. [email protected] wrote:

But when I require ‘net/ldap’ from inside a rails controller. Rails
complains that it cannot load

LoadError (no such file to load – net/ldap):
app/controllers/supplier_controller.rb:1

Try adding it on your Gemfile.


Erol M. Fornoles
http://erolfornoles.posterous.com
http://github.com/Erol
http://twitter.com/erolfornoles
http://ph.linkedin.com/in/erolfornoles

Thanks!

  1. Added gem ‘net-ldap’ to Gemfile
  2. ran bundle install

and it works now.

Peter (Guo) Pei wrote in post #957055:

I downloaded net-ldap gem and had no problem to use it from non-rail
applications.

But when I require ‘net/ldap’ from inside a rails controller. Rails
complains that it cannot load

LoadError (no such file to load – net/ldap):
app/controllers/supplier_controller.rb:1

You shouldn’t be calling it from inside your controllers anyway. That
sort of logic goes in a model.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs