Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在将我的 Rails 应用程序与旧数据库连接起来。其中一些表没有主键,我无法添加主键。
有什么方法可以将活动模型配置为没有主键?
谢谢!
您可以使用self.primary_key = <pk_field>如下方式定义主键:
self.primary_key = <pk_field>
class User < ActiveRecord::Base self.table_name = "user" self.primary_key = "id" end