本文介绍了为什么Rails的Composite_primary_keys gem不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已按照此处的说明进行安装通过

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

我明白了

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!

推荐答案

是否已按照require 'composite_primary_keys'添加到environment.rb文件的底部. rel ="noreferrer">在这里?

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

这篇关于为什么Rails的Composite_primary_keys gem不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 06:38