I've set up a database that has composite primary keys for Ruby on Rails. Creating the migration works, but when I start to seed the database, I still get a warning that "Active Record does not support primary keys." and that the "Composite primary key is ignored." even after I've installed the composite_primary_keys gem, and included require 'composite_primary_keys'
into the environments.rb
file.
我已经建立了一个具有Ruby on Rails复合主键的数据库。创建迁移有效,但是当我开始为数据库设定种子时,我仍然会收到“Active Record不支持主键”的警告。并且“忽略复合主键”。即使在我安装了composite_primary_keys gem之后,还要将'composite_primary_keys'包含在environments.rb文件中。
Any thoughts as to why the composite primary key is still ignored?
有关为什么仍然忽略复合主键的任何想法?
1 个解决方案
#1
1
Well, I found the work-around to this. For every model that I had that has composite primary keys, I included require 'composite_primary_keys
on the start of the class. Seems to work for me.
好吧,我找到了解决方法。对于我拥有复合主键的每个模型,我在类的开头包含了require'composite_primary_keys。似乎适合我。
#1
1
Well, I found the work-around to this. For every model that I had that has composite primary keys, I included require 'composite_primary_keys
on the start of the class. Seems to work for me.
好吧,我找到了解决方法。对于我拥有复合主键的每个模型,我在类的开头包含了require'composite_primary_keys。似乎适合我。