aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Bigg <radarlistener@gmail.com>2012-09-05 15:41:44 +0100
committerRyan Bigg <radarlistener@gmail.com>2012-09-05 15:42:43 +0100
commitbaa73ac723b9987a2ca66b76e0e788a7a3ef1c63 (patch)
treea45a3f93be2b47bb0722486a2df7934d66ffe4d4
parent1cb684c2ef12eea5661b17903f4986edfba0a464 (diff)
downloadrails-baa73ac723b9987a2ca66b76e0e788a7a3ef1c63.tar.gz
rails-baa73ac723b9987a2ca66b76e0e788a7a3ef1c63.tar.bz2
rails-baa73ac723b9987a2ca66b76e0e788a7a3ef1c63.zip
Add giant belongs_to 'please don't pluralize me' note
I've personally seen too many newbies get this wrong and pluralize the association
-rw-r--r--guides/source/association_basics.textile2
1 files changed, 2 insertions, 0 deletions
diff --git a/guides/source/association_basics.textile b/guides/source/association_basics.textile
index d4c0a1ba74..151752eee9 100644
--- a/guides/source/association_basics.textile
+++ b/guides/source/association_basics.textile
@@ -88,6 +88,8 @@ end
!images/belongs_to.png(belongs_to Association Diagram)!
+NOTE: +belongs_to+ associations _must_ use the singular term. If you used the pluralized form in the above example for the +customer+ association in the +Order+ model, you would be told that there was an "uninitialized constant Order::Customers". This is because Rails automatically infers the class name from the association name. If the association name is wrongly pluralized, then the inferred class will be wrongly pluralized too.
+
h4. The +has_one+ Association
A +has_one+ association also sets up a one-to-one connection with another model, but with somewhat different semantics (and consequences). This association indicates that each instance of a model contains or possesses one instance of another model. For example, if each supplier in your application has only one account, you'd declare the supplier model like this: