diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-01-11 02:23:49 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-01-11 02:25:38 +0900 |
commit | e81f20702a69ab5d8a8a150a5d1d178c0e1da792 (patch) | |
tree | 2f5c2c9a069f2f24aba675daf0233d3cc46dd376 /guides | |
parent | 3320e80b93f94d216fe03bc9183c867e421cc4d5 (diff) | |
parent | 4ab4364a51e7e95c15eaa09fc6b7234afcfbc6f4 (diff) | |
download | rails-e81f20702a69ab5d8a8a150a5d1d178c0e1da792.tar.gz rails-e81f20702a69ab5d8a8a150a5d1d178c0e1da792.tar.bz2 rails-e81f20702a69ab5d8a8a150a5d1d178c0e1da792.zip |
Merge pull request #31446 from bdewater/inverse-of-options-docs
Fix :inverse_of documentation
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/association_basics.md | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md index b5e236b790..02d012d702 100644 --- a/guides/source/association_basics.md +++ b/guides/source/association_basics.md @@ -735,12 +735,9 @@ a.first_name = 'David' a.first_name == b.author.first_name # => true ``` -Active Record supports automatic identification for most associations with standard names. However, Active Record will not automatically identify bi-directional associations that contain any of the following options: +Active Record supports automatic identification for most associations with standard names. However, Active Record will not automatically identify bi-directional associations that contain a scope or any of the following options: -* `:conditions` * `:through` -* `:polymorphic` -* `:class_name` * `:foreign_key` For example, consider the following model declarations: @@ -787,12 +784,6 @@ a.first_name = 'David' a.first_name == b.writer.first_name # => true ``` -There are a few limitations to `:inverse_of` support: - -* They do not work with `:through` associations. -* They do not work with `:polymorphic` associations. -* They do not work with `:as` associations. - Detailed Association Reference ------------------------------ @@ -1012,7 +1003,7 @@ When we execute `@user.todos.create` then the `@todo` record will have its ##### `:inverse_of` -The `:inverse_of` option specifies the name of the `has_many` or `has_one` association that is the inverse of this association. Does not work in combination with the `:polymorphic` options. +The `:inverse_of` option specifies the name of the `has_many` or `has_one` association that is the inverse of this association. ```ruby class Author < ApplicationRecord @@ -1082,7 +1073,7 @@ You can use any of the standard [querying methods](active_record_querying.html) The `where` method lets you specify the conditions that the associated object must meet. ```ruby -class book < ApplicationRecord +class Book < ApplicationRecord belongs_to :author, -> { where active: true } end ``` @@ -1299,7 +1290,7 @@ TIP: In any case, Rails will not create foreign key columns for you. You need to ##### `:inverse_of` -The `:inverse_of` option specifies the name of the `belongs_to` association that is the inverse of this association. Does not work in combination with the `:through` or `:as` options. +The `:inverse_of` option specifies the name of the `belongs_to` association that is the inverse of this association. ```ruby class Supplier < ApplicationRecord @@ -1694,7 +1685,7 @@ TIP: In any case, Rails will not create foreign key columns for you. You need to ##### `:inverse_of` -The `:inverse_of` option specifies the name of the `belongs_to` association that is the inverse of this association. Does not work in combination with the `:through` or `:as` options. +The `:inverse_of` option specifies the name of the `belongs_to` association that is the inverse of this association. ```ruby class Author < ApplicationRecord |