aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Lacan <hi@olivierlacan.com>2019-01-30 12:39:32 -0500
committerOlivier Lacan <hi@olivierlacan.com>2019-01-30 19:29:03 -0500
commit13f8beb435139bd96e27640e6d198b3ebf9cdecc (patch)
treee93b54d1d59ca63ce15375ff8e46b20320d6b3d9
parent826e34be226cbb61c28867617e1e37e20beae18f (diff)
downloadrails-13f8beb435139bd96e27640e6d198b3ebf9cdecc.tar.gz
rails-13f8beb435139bd96e27640e6d198b3ebf9cdecc.tar.bz2
rails-13f8beb435139bd96e27640e6d198b3ebf9cdecc.zip
Hint at advanced options for foreign_key
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]
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
index db489143af..80409232a3 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -680,9 +680,10 @@ module ActiveRecord
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)