method
foreign_key
v7.1.3.4 -
Show latest stable
- Class:
ActiveRecord::ConnectionAdapters::ColumnMethods::Table
foreign_key(*args, **options)public
Adds a foreign key to the table using a supplied table name.
t.foreign_key(:authors) t.foreign_key(:authors, column: :author_id, primary_key: "id")
See {connection.add_foreign_key}[rdoc-ref:SchemaStatements#add_foreign_key]