问题
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:
Did you add require 'composite_primary_keys'
to the bottom of your environment.rb
file as described here?
来源:https://stackoverflow.com/questions/2388995/why-isnt-the-composite-primary-keys-gem-for-rails-working