Skip to content

Commit

Permalink
Hint at advanced options for foreign_key
Browse files Browse the repository at this point in the history
We sometimes display simple examples of additional parameters that can be
supplied to table-wise methods like these and I found it particularly difficult
to figure out which options `t.foreign_key` accepts without drilling very deep
into the specific SchemaStatements docs.

Since it's relatively common to create foreign keys with custom column names or
primary keys, it seems like this should help quite a few people.

[ci skip]
  • Loading branch information
olivierlacan committed Jan 31, 2019
1 parent 826e34b commit 13f8beb
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -680,9 +680,10 @@ def remove_references(*args, **options)
end
alias :remove_belongs_to :remove_references

# Adds a foreign key.
# 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]
def foreign_key(*args)
Expand Down

0 comments on commit 13f8beb

Please sign in to comment.