<?xml version="1.0" encoding="UTF-8"?>
<ticket>
  <assigned-user-id type="integer">1366</assigned-user-id>
  <attachments-count type="integer">0</attachments-count>
  <closed type="boolean">true</closed>
  <created-at type="datetime">2008-09-08T20:58:30+01:00</created-at>
  <creator-id type="integer">7211</creator-id>
  <milestone-due-on type="datetime" nil="true"></milestone-due-on>
  <milestone-id type="integer" nil="true"></milestone-id>
  <number type="integer">11</number>
  <permalink>guide-to-active-record-associations</permalink>
  <priority type="integer">19707</priority>
  <project-id type="integer">16213</project-id>
  <raw-data type="binary" nil="true" encoding="base64"></raw-data>
  <state>published</state>
  <tag>activerecord</tag>
  <title>Guide to Active Record Associations</title>
  <updated-at type="datetime">2009-12-15T17:30:57+00:00</updated-at>
  <user-id type="integer">35500</user-id>
  <user-name>Todd</user-name>
  <creator-name>Mike Gunderloy</creator-name>
  <assigned-user-name>Pratik</assigned-user-name>
  <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
  <original-body></original-body>
  <latest-body></latest-body>
  <original-body-html></original-body-html>
  <versions type="array">
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body></body>
      <body-html></body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-09-08T20:58:30+01:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>new</state>
      <tag>activerecord associations</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2008-09-08T20:58:37+01:00</updated-at>
      <user-id type="integer">7211</user-id>
      <user-name>Mike Gunderloy</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>I've checked in a first cut at this one - doc/guides/activerecord/association_basics.txt. I need to clean up some of the AsciiDoc formatting, but it's to the point where comments are welcome.</body>
      <body-html>&lt;div&gt;&lt;p&gt;I've checked in a first cut at this one -
doc/guides/activerecord/association_basics.txt. I need to clean up
some of the AsciiDoc formatting, but it's to the point where
comments are welcome.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-09-08T20:59:21+01:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>new</state>
      <tag>activerecord associations</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2008-09-08T20:59:28+01:00</updated-at>
      <user-id type="integer">7211</user-id>
      <user-name>Mike Gunderloy</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Note : This had already been approved.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Note : This had already been approved.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-09-09T00:45:12+01:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>new</state>
      <tag>activerecord associations</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2008-09-09T00:45:17+01:00</updated-at>
      <user-id type="integer">1366</user-id>
      <user-name>Pratik</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>I just added some images and did some miscellaneous cleanup. Unless there's feedback, I think this one is finished.</body>
      <body-html>&lt;div&gt;&lt;p&gt;I just added some images and did some miscellaneous cleanup.
Unless there's feedback, I think this one is finished.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-09-22T16:20:04+01:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- 
:tag: activerecord associations
</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>new</state>
      <tag>activerecord associations</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2008-09-22T16:20:05+01:00</updated-at>
      <user-id type="integer">7211</user-id>
      <user-name>Mike Gunderloy</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>First of all, once again great guide. But since there's no feedback yet, I'll just dump here my rough notes since I probably won't have time to sort it our for a few days. Mostly nitpicking, though.
If there's something not clear enough, let me know and I'll try to clarify. Without further ado, here it is:

- model names are plural instead of singular at the beginning
- has_many :through is missing an &quot;end&quot; at the bottom of both code segments and Patient model picture has indentation bug
- code blocks needlessly repeated after the ER diagrams
- couldn't understand polymorphic associations. Where are :imageable and &quot;:as =&gt; :attachable&quot; on both models coming from. Isn't :as supposed to be different for those two models? What does Rails make out of :imageable and :attachable?
- clarify weather belongs_to :order :include =&gt; :order is needed in order to eager load the associated Order model or that one is eager loaded by default
- fonts for &lt; h5 &gt;&lt; tt &gt; should be made 20% bigger
- in 4.2.1 in &quot;Each instance of the order model will have these methods:&quot; &quot;order&quot; should be replace with &quot;supplier&quot;
- in 4.2.1 in build and create_association sections there is &quot;and the link through this its foreign key will be set&quot;
- in 4.3.1 each line in second code block is wrapped in + signs
- in 4.3.1 and 4.4.1 in collection&lt;&lt; there is &quot;_collection&lt;&lt;&quot; where _ is probably not supposed to be there
- in 4.3.1 should &quot;:dependent &#8658; :delete_all&quot; be &quot;:dependent &#8658; :delete&quot; instead? :delete_all is not mentioned in :dependent section
- in 4.3.1 in collection.create there is &quot;one a new&quot; where &quot;a&quot; needs to be removed
- in 4.3.2 there is &quot;This section cover &quot; where &quot;cover&quot; =&gt; &quot;covers&quot;
- in 4.3.2 :order there is &quot;(in the syntax used by a SQL WHERE clause)&quot;. &quot;WHERE&quot; =&gt; &quot;ORDER BY&quot;
- in 4.3.2 :include in both code blocks &quot;belongs_to :orders&quot;. Model should be singular I guess.
- in 4.4.1 after the list of 13 methods there is &quot;_collection_singular&quot; where leading _ probably shouldn't be there
- in 4.4.1 in first code block there is &quot;class Parts&quot; when it should probably be &quot;class Part&quot;
- in 4.4.1 second code block has excess plus signs
- in 4.4.1 collection.delete: &quot;join table+&quot;
- in 4.4.1 collection.clear: does it set associated model's foreign key to NULL?

I only had time to read up to section 4.4.2 so polymorphic associations my be explained better later in the guide.</body>
      <body-html>&lt;div&gt;&lt;p&gt;First of all, once again great guide. But since there's no
feedback yet, I'll just dump here my rough notes since I probably
won't have time to sort it our for a few days. Mostly nitpicking,
though. If there's something not clear enough, let me know and I'll
try to clarify. Without further ado, here it is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;model names are plural instead of singular at the
beginning&lt;/li&gt;
&lt;li&gt;has_many :through is missing an &quot;end&quot; at the bottom of both
code segments and Patient model picture has indentation bug&lt;/li&gt;
&lt;li&gt;code blocks needlessly repeated after the ER diagrams&lt;/li&gt;
&lt;li&gt;couldn't understand polymorphic associations. Where are
:imageable and &quot;:as =&amp;gt; :attachable&quot; on both models coming from.
Isn't :as supposed to be different for those two models? What does
Rails make out of :imageable and :attachable?&lt;/li&gt;
&lt;li&gt;clarify weather belongs_to :order :include =&amp;gt; :order is
needed in order to eager load the associated Order model or that
one is eager loaded by default&lt;/li&gt;
&lt;li&gt;fonts for &amp;lt; h5 &amp;gt;&amp;lt; tt &amp;gt; should be made 20%
bigger&lt;/li&gt;
&lt;li&gt;in 4.2.1 in &quot;Each instance of the order model will have these
methods:&quot; &quot;order&quot; should be replace with &quot;supplier&quot;&lt;/li&gt;
&lt;li&gt;in 4.2.1 in build and create_association sections there is &quot;and
the link through this its foreign key will be set&quot;&lt;/li&gt;
&lt;li&gt;in 4.3.1 each line in second code block is wrapped in +
signs&lt;/li&gt;
&lt;li&gt;in 4.3.1 and 4.4.1 in collection&amp;lt;&amp;lt; there is
&quot;_collection&amp;lt;&amp;lt;&quot; where _ is probably not supposed to be
there&lt;/li&gt;
&lt;li&gt;in 4.3.1 should &quot;:dependent &amp;#8658; :delete_all&quot; be &quot;:dependent
&amp;#8658; :delete&quot; instead? :delete_all is not mentioned in
:dependent section&lt;/li&gt;
&lt;li&gt;in 4.3.1 in collection.create there is &quot;one a new&quot; where &quot;a&quot;
needs to be removed&lt;/li&gt;
&lt;li&gt;in 4.3.2 there is &quot;This section cover &quot; where &quot;cover&quot; =&amp;gt;
&quot;covers&quot;&lt;/li&gt;
&lt;li&gt;in 4.3.2 :order there is &quot;(in the syntax used by a SQL WHERE
clause)&quot;. &quot;WHERE&quot; =&amp;gt; &quot;ORDER BY&quot;&lt;/li&gt;
&lt;li&gt;in 4.3.2 :include in both code blocks &quot;belongs_to :orders&quot;.
Model should be singular I guess.&lt;/li&gt;
&lt;li&gt;in 4.4.1 after the list of 13 methods there is
&quot;_collection_singular&quot; where leading _ probably shouldn't be
there&lt;/li&gt;
&lt;li&gt;in 4.4.1 in first code block there is &quot;class Parts&quot; when it
should probably be &quot;class Part&quot;&lt;/li&gt;
&lt;li&gt;in 4.4.1 second code block has excess plus signs&lt;/li&gt;
&lt;li&gt;in 4.4.1 collection.delete: &quot;join table+&quot;&lt;/li&gt;
&lt;li&gt;in 4.4.1 collection.clear: does it set associated model's
foreign key to NULL?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I only had time to read up to section 4.4.2 so polymorphic
associations my be explained better later in the guide.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-09-24T22:11:14+01:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>new</state>
      <tag>activerecord associations</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2008-09-24T22:11:15+01:00</updated-at>
      <user-id type="integer">718</user-id>
      <user-name>Nemanja</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Excellent feedback! Thanks. It helps *immensely* to have someone else doing a tech edit.

I'll start tidying these things up.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Excellent feedback! Thanks. It helps &lt;em&gt;immensely&lt;/em&gt; to have
someone else doing a tech edit.&lt;/p&gt;
&lt;p&gt;I'll start tidying these things up.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-09-24T22:17:52+01:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>new</state>
      <tag>activerecord associations</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2008-09-24T22:17:56+01:00</updated-at>
      <user-id type="integer">7211</user-id>
      <user-name>Mike Gunderloy</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>I've made most of these changes. Exceptions:

* I'm leaving the code snippets in the ER diagrams, even though they're redundant with the text, because I want the diagrams to be reusable separately.
* Changing fonts in the stylesheet should be left to the overall designer.</body>
      <body-html>&lt;div&gt;&lt;p&gt;I've made most of these changes. Exceptions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I'm leaving the code snippets in the ER diagrams, even though
they're redundant with the text, because I want the diagrams to be
reusable separately.&lt;/li&gt;
&lt;li&gt;Changing fonts in the stylesheet should be left to the overall
designer.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-09-26T10:36:34+01:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>new</state>
      <tag>activerecord associations</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2008-09-26T10:36:36+01:00</updated-at>
      <user-id type="integer">7211</user-id>
      <user-name>Mike Gunderloy</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body nil="true"></body>
      <body-html nil="true"></body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2008-09-30T00:08:36+01:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- 
:state: new
</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>resolved</state>
      <tag>activerecord associations</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2008-09-30T00:08:37+01:00</updated-at>
      <user-id type="integer">1366</user-id>
      <user-name>Pratik</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>I'm new to rails, but is this a possible error?:

The syntax recommended through out the guide for the :class_name option makes use of a symbol to refer to actual class name:

@@@
belongs_to :customer, :class_name =&gt; :user
@@@

Using this syntax caused me to get &quot;can't convert Symbol into String&quot; errors.

The following definition worked though!

@@@
belongs_to :customer, :class_name =&gt; &quot;User&quot;
@@@</body>
      <body-html>&lt;div&gt;&lt;p&gt;I'm new to rails, but is this a possible error?:&lt;/p&gt;
&lt;p&gt;The syntax recommended through out the guide for the :class_name
option makes use of a symbol to refer to actual class name:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
belongs_to :customer, :class_name =&amp;gt; :user
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Using this syntax caused me to get &quot;can't convert Symbol into
String&quot; errors.&lt;/p&gt;
&lt;p&gt;The following definition worked though!&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
belongs_to :customer, :class_name =&amp;gt; &amp;quot;User&amp;quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2008-10-09T19:22:41+01:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>resolved</state>
      <tag>activerecord associations</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2008-10-09T19:22:46+01:00</updated-at>
      <user-id type="integer">33930</user-id>
      <user-name>LK</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>You are absolutely right, and I am absolutely embarrassed. Thanks for pointing that out!</body>
      <body-html>&lt;div&gt;&lt;p&gt;You are absolutely right, and I am absolutely embarrassed.
Thanks for pointing that out!&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2008-10-11T23:56:05+01:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>resolved</state>
      <tag>activerecord associations</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2008-10-11T23:56:09+01:00</updated-at>
      <user-id type="integer">7211</user-id>
      <user-name>Mike Gunderloy</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>In 2.10 (Self Joins), the last line should be: `@employee.manager` instead of `@employee.managers`

(because `belongs_to` is a one-to-one association)</body>
      <body-html>&lt;div&gt;&lt;p&gt;In 2.10 (Self Joins), the last line should be:
&lt;code&gt;@employee.manager&lt;/code&gt; instead of
&lt;code&gt;@employee.managers&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;(because &lt;code&gt;belongs_to&lt;/code&gt; is a one-to-one
association)&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2008-10-28T10:12:16+00:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>resolved</state>
      <tag>activerecord associations</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2008-10-28T10:12:19+00:00</updated-at>
      <user-id type="integer">10258</user-id>
      <user-name>Dov Murik</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Thanks, fixed.

Y'all should feel free to send patches for tiny little typoes :)</body>
      <body-html>&lt;div&gt;&lt;p&gt;Thanks, fixed.&lt;/p&gt;
&lt;p&gt;Y'all should feel free to send patches for tiny little typoes
:)&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2008-10-28T11:16:54+00:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>resolved</state>
      <tag>activerecord associations</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2008-10-28T11:16:57+00:00</updated-at>
      <user-id type="integer">7211</user-id>
      <user-name>Mike Gunderloy</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Section 2.10 (Self Joins) is unclear to me.   I'm not sure if this is an error or not.  Should it read ':class_name =&gt; &quot;Employee&quot;'?  If it is correct as it stands, then what does the User class look like?  What is the relationship between them?

class Employee &lt; ActiveRecord::Base
  has_many :subordinates, :class_name =&gt; &quot;User&quot;, :foreign_key =&gt; &quot;manager_id&quot;
  belongs_to :manager, :class_name =&gt; &quot;User&quot;
end

Some more explanation seems desireable.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Section 2.10 (Self Joins) is unclear to me. I'm not sure if this
is an error or not. Should it read ':class_name =&amp;gt; &quot;Employee&quot;'?
If it is correct as it stands, then what does the User class look
like? What is the relationship between them?&lt;/p&gt;
&lt;p&gt;class Employee &amp;lt; ActiveRecord::Base has_many :subordinates,
:class_name =&amp;gt; &quot;User&quot;, :foreign_key =&amp;gt; &quot;manager_id&quot;
belongs_to :manager, :class_name =&amp;gt; &quot;User&quot; end&lt;/p&gt;
&lt;p&gt;Some more explanation seems desireable.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2008-11-10T00:54:33+00:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>resolved</state>
      <tag>activerecord associations</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2008-11-10T00:54:37+00:00</updated-at>
      <user-id type="integer">28039</user-id>
      <user-name>Brandon Zylstra</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Another great guide.  one error I found when talking about :offset ...

&quot;For example, if you set :offset &#8658; 11, it will skip the first 10 records.&quot;

That is technically true, but to be more precise, the first 11 records are skipped because :offset =&gt; 0 skips 0 records, :offset =&gt; 1 skips 1 records, etc.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Another great guide. one error I found when talking about
:offset ...&lt;/p&gt;
&lt;p&gt;&quot;For example, if you set :offset &amp;#8658; 11, it will skip the
first 10 records.&quot;&lt;/p&gt;
&lt;p&gt;That is technically true, but to be more precise, the first 11
records are skipped because :offset =&amp;gt; 0 skips 0 records,
:offset =&amp;gt; 1 skips 1 records, etc.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2008-11-18T15:28:37+00:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>resolved</state>
      <tag>activerecord associations</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2008-11-18T15:28:43+00:00</updated-at>
      <user-id type="integer">38006</user-id>
      <user-name>Anna Lissa Cruz</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Thanks for the corrections. New draft uploading.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Thanks for the corrections. New draft uploading.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2008-11-18T16:43:15+00:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>resolved</state>
      <tag>activerecord associations</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2008-11-18T16:43:17+00:00</updated-at>
      <user-id type="integer">7211</user-id>
      <user-name>Mike Gunderloy</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>looks like methods confused with parameters:

class CreateOrders &lt; ActiveRecord::Migration
  def self.up
    create_table :orders do |t|
      t.order_date   :datetime
      t.order_number :string
      t.customer_id  :integer
    end
  end</body>
      <body-html>&lt;div&gt;&lt;p&gt;looks like methods confused with parameters:&lt;/p&gt;
&lt;p&gt;class CreateOrders &amp;lt; ActiveRecord::Migration def self.up&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;create_table :orders do |t|
  t.order_date   :datetime
  t.order_number :string
  t.customer_id  :integer
end
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;end&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2008-11-27T15:28:08+00:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- 
:tag: activerecord associations
</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>resolved</state>
      <tag>activerecord</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2008-11-27T15:28:14+00:00</updated-at>
      <user-id type="integer">39101</user-id>
      <user-name>dmitry zhelnin</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Ugh, that was stupid, wasn't it? FIxed.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Ugh, that was stupid, wasn't it? FIxed.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2008-11-30T13:03:05+00:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>resolved</state>
      <tag>activerecord</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2008-11-30T13:03:09+00:00</updated-at>
      <user-id type="integer">7211</user-id>
      <user-name>Mike Gunderloy</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>it would be nice if there were some examples for the more complex options, eg finder_sql. there are already a few examples for these things in the normal rails API docs, but they are a bit light on the explanations i was hoping to find here. o/wise, this is a great little guide for the simple stuff.</body>
      <body-html>&lt;div&gt;&lt;p&gt;it would be nice if there were some examples for the more
complex options, eg finder_sql. there are already a few examples
for these things in the normal rails API docs, but they are a bit
light on the explanations i was hoping to find here. o/wise, this
is a great little guide for the simple stuff.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2008-12-02T21:16:51+00:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>resolved</state>
      <tag>activerecord</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2008-12-02T21:16:54+00:00</updated-at>
      <user-id type="integer">39590</user-id>
      <user-name>charlesdeb</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>In the first section, &quot;Why Associations?&quot;, the last example implies that the customers orders will be destroyed when the customer is. The problem is the orders association has not been declared as dependent. While the dependent option is explain further down, having users assume it is default behavior seems bad.</body>
      <body-html>&lt;div&gt;&lt;p&gt;In the first section, &quot;Why Associations?&quot;, the last example
implies that the customers orders will be destroyed when the
customer is. The problem is the orders association has not been
declared as dependent. While the dependent option is explain
further down, having users assume it is default behavior seems
bad.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-02-04T18:03:42+00:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>resolved</state>
      <tag>activerecord</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2009-02-04T18:03:44+00:00</updated-at>
      <user-id type="integer">17315</user-id>
      <user-name>Tristan Dunn</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>In the third code block:

@@@ @orders = Order.find_by_customer_id(@customer.id) @@@

is misleading. It should be @@@ find_all_by_customer_id @@@, otherwise the each loop makes no sense.</body>
      <body-html>&lt;div&gt;&lt;p&gt;In the third code block:&lt;/p&gt;
&lt;p&gt;@@@ @orders = Order.find_by_customer_id(@customer.id) @@@&lt;/p&gt;
&lt;p&gt;is misleading. It should be @@@ find_all_by_customer_id @@@,
otherwise the each loop makes no sense.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-04-11T16:04:35+01:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- 
:state: resolved
</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state nil="true"></state>
      <tag>activerecord</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2009-04-11T16:04:39+01:00</updated-at>
      <user-id type="integer">29693</user-id>
      <user-name>Kai Krakow</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body nil="true"></body>
      <body-html nil="true"></body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-04-11T16:09:40+01:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- 
:state: 
</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>published</state>
      <tag>activerecord</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2009-04-11T16:09:44+01:00</updated-at>
      <user-id type="integer">1366</user-id>
      <user-name>Pratik</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>In the sections 4.3.1 and 4.4.1 is the following code: 

collection.exist?(&#8230;)

which I guess it should be collection.exists?(&#8230;) instead off. I have tested in 2.2.x and 2.3.x</body>
      <body-html>&lt;div&gt;&lt;p&gt;In the sections 4.3.1 and 4.4.1 is the following code:&lt;/p&gt;
&lt;p&gt;collection.exist?(&amp;#8230;)&lt;/p&gt;
&lt;p&gt;which I guess it should be collection.exists?(&amp;#8230;) instead
off. I have tested in 2.2.x and 2.3.x&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-05-21T11:50:27+01:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- 
:assigned_user: 1366
</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>published</state>
      <tag>activerecord</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2009-05-21T11:50:31+01:00</updated-at>
      <user-id type="integer">53443</user-id>
      <user-name>Peter Zlatnar</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Thanks Peter, fixed in http://github.com/lifo/docrails/commit/402f08f1efe5dbfbf1cdd4db8b7c6c4bc91574a6</body>
      <body-html>&lt;div&gt;&lt;p&gt;Thanks Peter, fixed in &lt;a href=
&quot;http://github.com/lifo/docrails/commit/402f08f1efe5dbfbf1cdd4db8b7c6c4bc91574a6&quot;&gt;
http://github.com/lifo/docrails/commit/402f08f1efe5dbfbf1cdd4db8b7c...&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-05-23T22:57:10+01:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- 
:assigned_user: 
</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>published</state>
      <tag>activerecord</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2009-05-23T22:57:13+01:00</updated-at>
      <user-id type="integer">11378</user-id>
      <user-name>Xavier Noria</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Kai: fixed in http://github.com/lifo/docrails/commit/39ad75bda2e140008024543692e0c7019a5a4632

Thank you!</body>
      <body-html>&lt;div&gt;&lt;p&gt;Kai: fixed in &lt;a href=
&quot;http://github.com/lifo/docrails/commit/39ad75bda2e140008024543692e0c7019a5a4632&quot;&gt;
http://github.com/lifo/docrails/commit/39ad75bda2e140008024543692e0...&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-05-23T23:06:27+01:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>published</state>
      <tag>activerecord</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2009-05-23T23:06:29+01:00</updated-at>
      <user-id type="integer">11378</user-id>
      <user-name>Xavier Noria</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>This is a nice guide but I still am having trouble understanding why associations are used
and why some don't appear to work.  For example, the following ruby code works but does not work in an actual rails application.  It would help me to understand this better is I understood why something like this is not possible.  Is there a reason why I need to always use an extra table for a has_many_and_belongs_to relationship?  When I try this in Rails, its willing to do a part of this (e.g, e.department) but not the last '.customers' part?  I could of course just to x = e.department and then do x.customers (which does
work in Rails) but why do I need to do this in two steps instead of one?  I can see that for large datasets why the additional table would help but if the dataset is small why do you need the extra table/steps?

SAMPLE CODE
  require 'rubygems';require 'active_record'; require 'mysql';
  ActiveRecord::Base.establish_connection(:adapter =&gt;
'mysql', :database =&gt; &quot;idea&quot;, :username =&gt; &quot;myname&quot;, :password =&gt;
'mypswd')

class Employee &lt; ActiveRecord::Base
        belongs_to :department
end
class Department &lt; ActiveRecord::Base
        has_many :departments
        has_many :comments
end
class Customers &lt; ActiveRecord::Base
        belongs_to :department
end
e = Employee.find(1)
#to find the number of customers associated with a particular employee
within a department
p e.department.customers.size</body>
      <body-html>&lt;div&gt;&lt;p&gt;This is a nice guide but I still am having trouble understanding
why associations are used&lt;br&gt;
and why some don't appear to work. For example, the following ruby
code works but does not work in an actual rails application. It
would help me to understand this better is I understood why
something like this is not possible. Is there a reason why I need
to always use an extra table for a has_many_and_belongs_to
relationship? When I try this in Rails, its willing to do a part of
this (e.g, e.department) but not the last '.customers' part? I
could of course just to x = e.department and then do x.customers
(which does&lt;br&gt;
work in Rails) but why do I need to do this in two steps instead of
one? I can see that for large datasets why the additional table
would help but if the dataset is small why do you need the extra
table/steps?&lt;/p&gt;
&lt;p&gt;SAMPLE CODE&lt;br&gt;
require 'rubygems';require 'active_record'; require 'mysql';
ActiveRecord::Base.establish_connection(:adapter =&amp;gt; 'mysql',
:database =&amp;gt; &quot;idea&quot;, :username =&amp;gt; &quot;myname&quot;, :password =&amp;gt;
'mypswd')&lt;/p&gt;
&lt;p&gt;class Employee &amp;lt; ActiveRecord::Base&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;    belongs_to :department&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;end&lt;br&gt;
class Department &amp;lt; ActiveRecord::Base&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;    has_many :departments
    has_many :comments&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;end&lt;br&gt;
class Customers &amp;lt; ActiveRecord::Base&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;    belongs_to :department&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;end&lt;br&gt;
e = Employee.find(1)&lt;br&gt;&lt;/p&gt;
&lt;h1&gt;to find the number of customers associated with a particular
employee&lt;/h1&gt;
&lt;p&gt;within a department&lt;br&gt;
p e.department.customers.size&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-12-15T00:24:44+00:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>published</state>
      <tag>activerecord</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2009-12-15T00:24:47+00:00</updated-at>
      <user-id type="integer">35500</user-id>
      <user-name>Todd</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>woops,  I made a couple of typos.  The models should be 

class Employee &lt; ActiveRecord::Base
        belongs_to :department
end
class Department &lt; ActiveRecord::Base
        has_many :departments
        has_many :customers
end
class Customer &lt; ActiveRecord::Base
        belongs_to :department
end</body>
      <body-html>&lt;div&gt;&lt;p&gt;woops, I made a couple of typos. The models should be&lt;/p&gt;
&lt;p&gt;class Employee &amp;lt; ActiveRecord::Base&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;    belongs_to :department&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;end&lt;br&gt;
class Department &amp;lt; ActiveRecord::Base&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;    has_many :departments
    has_many :customers&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;end&lt;br&gt;
class Customer &amp;lt; ActiveRecord::Base&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;    belongs_to :department&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;end&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-12-15T06:46:03+00:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>published</state>
      <tag>activerecord</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2009-12-15T06:46:06+00:00</updated-at>
      <user-id type="integer">35500</user-id>
      <user-name>Todd</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>I figured out why is doesn't work and to my great shame, I'd actually
read this article http://blog.hasmanythrough.com/2008/2/27/count-length-size

In rails, you need to use .count and not .size for this to work
because the first collection has already been loaded and therefore you
are asking for the length and not the count!  The length == 0 and so
no records are returned.</body>
      <body-html>&lt;div&gt;&lt;p&gt;I figured out why is doesn't work and to my great shame, I'd
actually&lt;br&gt;
read this article &lt;a href=
&quot;http://blog.hasmanythrough.com/2008/2/27/count-length-size&quot;&gt;http://blog.hasmanythrough.com/2008/2/27/count-length-size&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In rails, you need to use .count and not .size for this to
work&lt;br&gt;
because the first collection has already been loaded and therefore
you&lt;br&gt;
are asking for the length and not the count! The length == 0 and
so&lt;br&gt;
no records are returned.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-12-15T17:30:54+00:00</created-at>
      <creator-id type="integer">7211</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">11</number>
      <permalink>guide-to-active-record-associations</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16213</project-id>
      <state>published</state>
      <tag>activerecord</tag>
      <title>Guide to Active Record Associations</title>
      <updated-at type="datetime">2009-12-15T17:30:57+00:00</updated-at>
      <user-id type="integer">35500</user-id>
      <user-name>Todd</user-name>
      <creator-name>Mike Gunderloy</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/16213/tickets/11</url>
    </version>
  </versions>
</ticket>
