[Ruby-activeldap-discuss] Patch for Rails 2.2.2

Jared Crapo jared at kotfu.net
Wed Feb 11 12:06:00 EST 2009


I have Rails 2.2.2, and checked out the trunk of activeldap in to vendor/activeldap-trunk. When I try and use the model_active_ldap generator, the following occurs: 

$ script/generate model_active_ldap user --backtrace 
You have a nil object when you didn't expect it! 
The error occurred while evaluating nil.demodulize 
/home/jared/src/amr/vendor/activeldap-trunk/rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb:57:in `default_prefix' 
/home/jared/src/amr/vendor/activeldap-trunk/rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb:40:in `add_options!' 
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails_generator/scripts/../options.rb:86:in `parse!' 
/usr/lib/ruby/1.8/optparse.rb:785:in `initialize' 
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails_generator/scripts/../options.rb:84:in `new' 
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails_generator/scripts/../options.rb:84:in `parse!' 
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails_generator/base.rb:103:in `initialize' 
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails_generator/base.rb:204:in `initialize' 
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails_generator/lookup.rb:140:in `new' 
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails_generator/lookup.rb:140:in `instance' 
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails_generator/scripts/../scripts.rb:31:in `run' 
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/generate.rb:6 
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' 
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' 
script/generate:3 

In Rails 2.2 the Inflector class has been moved into the ActiveSupport library, causing this generator to break. Here's a patch that fixes it: 

Index: rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb 
=================================================================== 
--- rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb (revision 829) 
+++ rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb (working copy) 
@@ -54,7 +54,7 @@ 
end 

def default_prefix 
- "ou=#{name.demodulize.pluralize}" 
+ "ou=#{ActiveSupport::Inflector.pluralize(ActiveSupport::Inflector.demodulize(name))}" 
end 

def ldap_mapping(indent=' ') 


Regards, 
Jared 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ruby-activeldap-discuss/attachments/20090211/c520a65d/attachment.html>


More information about the Ruby-activeldap-discuss mailing list