aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source
diff options
context:
space:
mode:
authorRyan Bigg <radarlistener@gmail.com>2010-12-02 13:29:17 +1100
committerRyan Bigg <radarlistener@gmail.com>2010-12-02 13:29:17 +1100
commit697f734455753ad23ba719539bf961c6f1bc45d2 (patch)
tree938a10e727ca49d60305238989dc2d809bc9ef06 /railties/guides/source
parent949eb91d0e771c14218f34f14cb4f00c09af60db (diff)
downloadrails-697f734455753ad23ba719539bf961c6f1bc45d2.tar.gz
rails-697f734455753ad23ba719539bf961c6f1bc45d2.tar.bz2
rails-697f734455753ad23ba719539bf961c6f1bc45d2.zip
Associations guide: Add note that you must use the build_ prefix to build associations of the belongs_to and has_one type
Diffstat (limited to 'railties/guides/source')
-rw-r--r--railties/guides/source/association_basics.textile4
1 files changed, 4 insertions, 0 deletions
diff --git a/railties/guides/source/association_basics.textile b/railties/guides/source/association_basics.textile
index 14bbe907f3..2043daa4ed 100644
--- a/railties/guides/source/association_basics.textile
+++ b/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+.