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
Run Code Online (Sandbox Code Playgroud)