views:

309

answers:

1

I followed the steps here and installed the composite_primary_keys gem. When I try to require the gem in environment.rb at the very bottom of the file (after 'end') via

require 'composite_primary_keys'

I get this when starting the server

"69125"
=> Booting Mongrel
=> Rails 2.3.4 application starting on http://127.0.0.1:3002
/Library/Ruby/Site/1.8/rubygems.rb:270:in `activate': You have a nil object when you didn't expect it! (NoMethodError)
You might have expected an instance of Array.
The error occurred while evaluating nil.map
 from /Library/Ruby/Site/1.8/rubygems.rb:296:in `activate'
 from /Library/Ruby/Site/1.8/rubygems.rb:295:in `each'
 from /Library/Ruby/Site/1.8/rubygems.rb:295:in `activate'
 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:35:in `require'
 from /path/to/www/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
 from /path/to/www/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
 from /path/to/www/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
 from /path/to/www/config/environment.rb:54
 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
 from /path/to/www/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
 from /path/to/www/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
 from /path/to/www/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
 from /path/to/www/vendor/rails/railties/lib/commands/server.rb:84
 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
 from ./script/server:3
 from -e:2:in `load'
 from -e:2

Any idea why this is happening?

+2  A: 

Try putting it in your environment.rb like this:

Rails::Initializer.run do |config|

  config.gem 'composite_primary_keys'

end
Trevoke
Hm, I think my rails installation is screwed up or something. Now I can't even start the server WITHOUT any changes. I'm gem updating, and we'll see what happens.
Chad Johnson
Now I get this when running script/server: Library/Ruby/Site/1.8/rubygems.rb:220:in `activate': undefined method `map' for nil:NilClass (NoMethodError)
Chad Johnson
Er, you didn't erase everything in environment.rb, did you? I just gave you a blank example, but there's some other stuff that fits in there, like the timezone settings .. Please edit your original post with the full error log from starting the server.
Trevoke
Okay, fixed this by reverting and patching in changes. Now I get this when using config.gem to include the gem:/Library/Ruby/Site/1.8/rubygems.rb:220:in `activate': undefined method `map' for nil:NilClass (NoMethodError)
Chad Johnson
Can you show us your entire environment.rb (minus the comments) ? Also, are you running in development mode (the default) ?
Trevoke
YAY! I got it working! I had two versions of rake installed, so I uninstalled both, installed 1.1.0, reinstalled rails, and the config.gem call in environment.rb works now! YAY! Thanks for your help and patience!
Chad Johnson
You did most of the work :) Glad I was able to help though!
Trevoke