views:

121

answers:

1

I've followed the instructions here, installing the composite_primary_keys gem via

sudo gem install composite_primary_keys

That worked fine. Now when I add the following to my model

set_primary_keys :user_id, :group_id

and I get

undefined method `set_primary_keys' for #<Class:0x1043bfe20>

Also, using multiple primary keys in a migration as described here has no effect.

Any ideas why this might not be working and how to make it work?

Note: I do not want a speech on why I should not be using composite keys--I have already made up my mind and just want to get this working. Thanks!

+1  A: 

Did you add require 'composite_primary_keys' to the bottom of your environment.rb file as described here?

theIV
Okay, this clearly is the problem. Thanks. I'm still a bit new to Rails. I'm getting some errors when requiring this, but I'll figure it out and mark this as the answer if it solves the problem I described.
Chad Johnson
What kind of errors are you getting now?
theIV
http://stackoverflow.com/questions/2389129/why-am-i-getting-an-error-when-requiring-this-gem-in-environment-rb I think my rails install is jacked up or something. I'll try to fix this and let you know 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
Okay, I fixed this by reverting and patching in changes. Yay. Now I get this with the require /Library/Ruby/Site/1.8/rubygems.rb:220:in `activate': You have a nil object when you didn't expect it! (NoMethodError) (AFTER end) and /Library/Ruby/Site/1.8/rubygems.rb:220:in `activate': undefined method `map' for nil:NilClass (NoMethodError) (BEFORE end).
Chad Johnson
YAY! I got it working! I had two versions of rake installed, so I uninstalled both, installed 1.1.0, reinstalled rails, and the require call in environment.rb works now! YAY!
Chad Johnson
Very glad to hear that it worked. That is definitely a specific issue that I would not have been able to figure out through SO. Good job :)
theIV