rails 中的 'primary key' 是什么?

what is 'primary key' in rails?

我阅读了文章 "By default, all the models in RoR has a column called id of the type :primary_key."

于是查看了我的c9项目的schema文件,发现自动创建的对象只有

t.datetime "created_at", null: false
t.datetime "updated_at", null: false

根据上述文章,

t.primary_key"id"、null:false在哪里??

我只是一个初学者,所以请有人帮助我。 如果添加易于理解的示例,将非常感谢

主键不会存在于架构中,但 rails 所做的是,每当创建新的 table 时,它都会隐式添加一个主键列。当您迁移模型的 ruby 文件时会发生这种情况。更多信息 check this link

如果你是新手,我建议你Rails Guides彻底通关

默认情况下,Active Record 将使用一个名为 id 的整数列作为 table 的主键。使用 Active Record Migrations 创建您的 table 时,将自动创建此列。

这将帮助您更好地理解:guides