为什么Rails 的composite_primary_keys gem 不起作用?

发布于 2024-08-23 18:59:37 字数 696 浏览 3 评论 0 原文

我已按照此处的说明安装composite_primary_keys gem通过

sudo gem install composite_primary_keys

那工作得很好。现在,当我将以下内容添加到我的模型中时

set_primary_keys :user_id, :group_id

,我得到

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

Also, using multiple Primary Key in a miguration as所述 此处没有效果。

有什么想法为什么这可能不起作用以及如何使其起作用吗?

注意:我不想想要就为什么我不应该使用复合键发表演讲——我已经下定决心,只想让它发挥作用。谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我乃一代侩神 2024-08-30 18:59:38

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文