Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Associations guide: Add note that you must use the build_ prefix to b…

…uild associations of the belongs_to and has_one type
  • Loading branch information...
commit 697f734455753ad23ba719539bf961c6f1bc45d2 1 parent 949eb91
@radar radar authored
Showing with 4 additions and 0 deletions.
  1. +4 −0 railties/guides/source/association_basics.textile
View
4 railties/guides/source/association_basics.textile
@@ -550,6 +550,8 @@ build_customer
create_customer
</ruby>
+NOTE: When creating a new +belongs_to+ or +has_one+ association you must use the +build_+ prefix to build the association, rather than the +association.build+ method that would be used for +has_many+ or +has_and_belongs_to_many+ associations.
+
h6(#belongs_to-association). <tt><em>association</em>(force_reload = false)</tt>
The <tt><em>association</em></tt> method returns the associated object, if any. If no associated object is found, it returns +nil+.
@@ -817,6 +819,8 @@ build_account
create_account
</ruby>
+NOTE: When creating a new +has_one+ or +belongs_to+ association you must use the +build_+ prefix to build the association, rather than the +association.build+ method that would be used for +has_many+ or +has_and_belongs_to_many+ associations.
+
h6(#has_one-association). <tt><em>association</em>(force_reload = false)</tt>
The <tt><em>association</em></tt> method returns the associated object, if any. If no associated object is found, it returns +nil+.
Please sign in to comment.
Something went wrong with that request. Please try again.