我有以下型号:belongs_to在Rails 5中创建关联吗?
class User
has_many :items
end
class Item
belongs_to :user
end
内create_table
为items
我:
t.belongs_to :person
我用Rails 5,我看到这个自动创建person_id
的items
表中的索引。但是,根据这个SO thread,这不应该发生。
答案是不正确的,或者这是添加到Rails 5(或某些Rails 4.x版本)?
'person_id'在迁移和类是用户。这是正确的吗?因为如果是这样,这改变了事情。 – lcguida