Method: ActiveRecord::ConnectionAdapters::TableDefinition#references

Defined in:
activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb

#references(*args, **options) ⇒ Object Also known as: belongs_to

Adds a reference.

t.references(:user)
t.belongs_to(:supplier, foreign_key: true)
t.belongs_to(:supplier, foreign_key: true, type: :integer)

See connection.add_reference for details of the options you can use.



551
552
553
554
555
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 551

def references(*args, **options)
  args.each do |ref_name|
    ReferenceDefinition.new(ref_name, **options).add_to(self)
  end
end