В чем разница между t.belongs_to и t.references в рельсах?

В чем разница между t.references и t.belongs_to ? Почему у нас есть эти два разных слова? Мне кажется, они делают то же самое? Попробовал поискать в Google, но не нашел объяснения.

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
117
задан Nguyen You 26 June 2019 в 14:19
поделиться