我想我需要在 Rails 中使用 STI。
这是我的课:
class Person < ActiveRecord::Base
end
class Landlord < Person
end
people 表有一:type
列是字符串。
所以,我期望在表中看到的是,作为 Person 的每一行的类型都设置为“Person”,每个 Landlord 的类型都设置为“Landlord”。然而,这不是我所看到的。每个 Landlord 的类型设置为“Landlord”,但所有 Person 的类型都设置为 nil。这很可能是 rails 的工作方式,但我只是在寻找一些确认。