10

I'm using ActiveRecord in a ruby project without rails. I need to define composite primary key for a table.Normally migration creates primary key automatically. Is it possible to define my own composite primary key for a table using active record?

4

2 回答 2

7

有一些宝石可以为您提供这种能力,例如composite_primary_key

我不知道 Rails 4 是否增加了对此的支持,如果有的话我会很感兴趣。

于 2013-07-26T13:11:30.390 回答
1

之前已经问过问题,结帐:如何在Rails应用程序中设置复合键

http://compositekeys.rubyforge.org/也可能有用。

于 2013-07-26T13:11:16.850 回答