From baa73ac723b9987a2ca66b76e0e788a7a3ef1c63 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Wed, 5 Sep 2012 15:41:44 +0100 Subject: Add giant belongs_to 'please don't pluralize me' note I've personally seen too many newbies get this wrong and pluralize the association --- guides/source/association_basics.textile | 2 ++ 1 file changed, 2 insertions(+) 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: -- cgit v1.2.3