最佳答案
t.references
和 t.belongs_to
有什么不同?
为什么我们有这两个不同的词? 在我看来,他们做同样的事情?
尝试了一些谷歌搜索,但找不到任何解释。
class CreateFoos < ActiveRecord::Migration
def change
create_table :foos do |t|
t.references :bar
t.belongs_to :baz
# The two above seems to give similar results
t.belongs_to :fooable, :polymorphic => true
# I have not tried polymorphic with t.references
t.timestamps
end
end
end