aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2018-07-18 16:31:42 -0400
committerRafael Mendonça França <rafaelmfranca@gmail.com>2018-07-18 16:31:42 -0400
commitdc1c679d897281e92eef9f7540e540eb6334f94c (patch)
tree134b8282cddc6cf7620c0ee2d82b28cb67172aea /guides/source
parent5df23a04a31e95beb9a5728851345a68b3bca2ac (diff)
downloadrails-dc1c679d897281e92eef9f7540e540eb6334f94c.tar.gz
rails-dc1c679d897281e92eef9f7540e540eb6334f94c.tar.bz2
rails-dc1c679d897281e92eef9f7540e540eb6334f94c.zip
Revert "Merge pull request #33385 from lanzhiheng/add-example-for-has-and-belongs-to-many-association"
This reverts commit 3c8c410012e34709f3fdfe5b6a571353b20d0c56, reversing changes made to daee94da99605d89854660b63d98e4c1dc9a979d. We have this information below in the reference section for has_and_belongs_to_many.
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/association_basics.md16
1 files changed, 0 insertions, 16 deletions
diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md
index e13f4b6aaf..e7408b5a7f 100644
--- a/guides/source/association_basics.md
+++ b/guides/source/association_basics.md
@@ -365,22 +365,6 @@ class CreateAssembliesAndParts < ActiveRecord::Migration[5.0]
end
```
-As you can see we don't create the relevant model for `assemblies_parts` table, So We can't create the many-to-many record like this
-
-``` ruby
-AssemblyPart.create(assembly: @assembly, part: @part) # => NameError: uninitialized constant AssemblyPart
-```
-
-If you want to create the relevant many-to-many record, you can use the below code
-
-``` ruby
-@assembly.parts << @part
-# Or
-@part.assemblies << @assembly
-```
-
-They are equivalent.
-
### Choosing Between `belongs_to` and `has_one`
If you want to set up a one-to-one relationship between two models, you'll need to add `belongs_to` to one, and `has_one` to the other. How do you know which is which?