instance method
foreign_key
Ruby on Rails 6.1.7.10
Since v5.2.8.1Signature
foreign_key(*args, **options)
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")
Parameters
-
argsrest -
optionskeyrest
Source
# File activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb, line 764
def foreign_key(*args, **options)
@base.add_foreign_key(name, *args, **options)
end
Defined in activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb line 764
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionAdapters::Table