<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: has_many :through Self-referential Example</title>
	<atom:link href="http://www.aldenta.com/2006/11/10/has_many-through-self-referential-example/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.aldenta.com/2006/11/10/has_many-through-self-referential-example/</link>
	<description>Handcrafting the Web by John Ford</description>
	<lastBuildDate>Wed, 03 Mar 2010 01:06:28 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0-alpha</generator>
	<item>
		<title>By: Sunil</title>
		<link>http://www.aldenta.com/2006/11/10/has_many-through-self-referential-example/comment-page-1/#comment-35168</link>
		<dc:creator>Sunil</dc:creator>
		<pubDate>Wed, 17 Jun 2009 06:49:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.aldenta.com/2006/11/11/has_many-through-self-referential-example/#comment-35168</guid>
		<description>Hi ,
 I wanted to know how i can set &quot;authorized&quot; field to true.. Actually what I am doing is, current user can add another user as friend(which will send him a friendship request).
 Now, when he clicks on Add user or allow user I want to set authorized to true. But since there is no id field in the table, I can neither say update_attribute nor can i call save! method.
Thanks for any help
Sunil</description>
		<content:encoded><![CDATA[<p>Hi ,<br />
 I wanted to know how i can set &#8220;authorized&#8221; field to true.. Actually what I am doing is, current user can add another user as friend(which will send him a friendship request).<br />
 Now, when he clicks on Add user or allow user I want to set authorized to true. But since there is no id field in the table, I can neither say update_attribute nor can i call save! method.<br />
Thanks for any help<br />
Sunil</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anonymous</title>
		<link>http://www.aldenta.com/2006/11/10/has_many-through-self-referential-example/comment-page-1/#comment-28061</link>
		<dc:creator>anonymous</dc:creator>
		<pubDate>Wed, 25 Feb 2009 17:09:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.aldenta.com/2006/11/11/has_many-through-self-referential-example/#comment-28061</guid>
		<description>Very nice article.  

Anyone have any suggestions getting this to work when both the friendships table and the persons table are using STI?

I have been trying but keep on getting AsociationTypeMismatch errors.</description>
		<content:encoded><![CDATA[<p>Very nice article.  </p>
<p>Anyone have any suggestions getting this to work when both the friendships table and the persons table are using STI?</p>
<p>I have been trying but keep on getting AsociationTypeMismatch errors.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Giorgio</title>
		<link>http://www.aldenta.com/2006/11/10/has_many-through-self-referential-example/comment-page-1/#comment-26783</link>
		<dc:creator>Giorgio</dc:creator>
		<pubDate>Sat, 31 Jan 2009 01:14:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.aldenta.com/2006/11/11/has_many-through-self-referential-example/#comment-26783</guid>
		<description>You made my day John.
:)

And also very well commented.

Thanks</description>
		<content:encoded><![CDATA[<p>You made my day John.<br />
:)</p>
<p>And also very well commented.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel</title>
		<link>http://www.aldenta.com/2006/11/10/has_many-through-self-referential-example/comment-page-1/#comment-15000</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Wed, 04 Jun 2008 17:59:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.aldenta.com/2006/11/11/has_many-through-self-referential-example/#comment-15000</guid>
		<description>this was helpful.  particularly the comment in the example source:

# tell ActiveRecord that a person has_many friendships or :through won&#039;t work

thanks!</description>
		<content:encoded><![CDATA[<p>this was helpful.  particularly the comment in the example source:</p>
<p># tell ActiveRecord that a person has_many friendships or :through won&#8217;t work</p>
<p>thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Ford</title>
		<link>http://www.aldenta.com/2006/11/10/has_many-through-self-referential-example/comment-page-1/#comment-14154</link>
		<dc:creator>John Ford</dc:creator>
		<pubDate>Tue, 22 Apr 2008 17:39:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.aldenta.com/2006/11/11/has_many-through-self-referential-example/#comment-14154</guid>
		<description>art, Are you using destroy or delete?  Remember, in rails that delete just deletes the record from the database but destroy will call the correct callbacks to destroy associated objects.</description>
		<content:encoded><![CDATA[<p>art, Are you using destroy or delete?  Remember, in rails that delete just deletes the record from the database but destroy will call the correct callbacks to destroy associated objects.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: art</title>
		<link>http://www.aldenta.com/2006/11/10/has_many-through-self-referential-example/comment-page-1/#comment-14142</link>
		<dc:creator>art</dc:creator>
		<pubDate>Tue, 22 Apr 2008 06:07:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.aldenta.com/2006/11/11/has_many-through-self-referential-example/#comment-14142</guid>
		<description>When removing a friend, would you have to manually remove the friendship as well as the friend?

current_user.friends.delete(unwanted_friend)

and

unwanted_relationship = current_user.relationships.find_by_friend_id...
current_user.relationships.delete(unwanted_relationship)</description>
		<content:encoded><![CDATA[<p>When removing a friend, would you have to manually remove the friendship as well as the friend?</p>
<p>current_user.friends.delete(unwanted_friend)</p>
<p>and</p>
<p>unwanted_relationship = current_user.relationships.find_by_friend_id&#8230;<br />
current_user.relationships.delete(unwanted_relationship)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike McKinney</title>
		<link>http://www.aldenta.com/2006/11/10/has_many-through-self-referential-example/comment-page-1/#comment-12303</link>
		<dc:creator>Mike McKinney</dc:creator>
		<pubDate>Fri, 15 Feb 2008 18:45:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.aldenta.com/2006/11/11/has_many-through-self-referential-example/#comment-12303</guid>
		<description>Just wanted to thank you for this post... it really helped me out today.</description>
		<content:encoded><![CDATA[<p>Just wanted to thank you for this post&#8230; it really helped me out today.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Ford</title>
		<link>http://www.aldenta.com/2006/11/10/has_many-through-self-referential-example/comment-page-1/#comment-11726</link>
		<dc:creator>John Ford</dc:creator>
		<pubDate>Tue, 29 Jan 2008 19:17:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.aldenta.com/2006/11/11/has_many-through-self-referential-example/#comment-11726</guid>
		<description>Rails won&#039;t be able to tell what table to use in that case without giving the source.  Here&#039;s what the documentation has to say about has_many source:

&lt;blockquote&gt;
:source: Specifies the source association name used by has_many :through queries. Only use it if the name cannot be inferred from the association. has_many :subscribers, :through =&gt; :subscriptions will look for either :subscribers or :subscriber on Subscription, unless a :source is given.
&lt;/blockquote&gt;</description>
		<content:encoded><![CDATA[<p>Rails won&#8217;t be able to tell what table to use in that case without giving the source.  Here&#8217;s what the documentation has to say about has_many source:</p>
<blockquote><p>
:source: Specifies the source association name used by has_many :through queries. Only use it if the name cannot be inferred from the association. has_many :subscribers, :through => :subscriptions will look for either :subscribers or :subscriber on Subscription, unless a :source is given.
</p></blockquote>
]]></content:encoded>
	</item>
	<item>
		<title>By: Todd</title>
		<link>http://www.aldenta.com/2006/11/10/has_many-through-self-referential-example/comment-page-1/#comment-11593</link>
		<dc:creator>Todd</dc:creator>
		<pubDate>Fri, 25 Jan 2008 18:18:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.aldenta.com/2006/11/11/has_many-through-self-referential-example/#comment-11593</guid>
		<description>Nice example. Quick question:

# create the has_many :through relationship
has_many :friends, :through =&gt; :friendships

# an example of how to get only the authorized friends
has_many :authorized_friends, :through =&gt; :friendships, 
  :source =&gt; :friend, :conditions =&gt; [ &quot;authorized = ?&quot;, true ]

Why do you need :source in :authorized_friends but not in :frinds?</description>
		<content:encoded><![CDATA[<p>Nice example. Quick question:</p>
<p># create the has_many :through relationship<br />
has_many :friends, :through =&gt; :friendships</p>
<p># an example of how to get only the authorized friends<br />
has_many :authorized_friends, :through =&gt; :friendships,<br />
  :source =&gt; :friend, :conditions =&gt; [ "authorized = ?", true ]</p>
<p>Why do you need :source in :authorized_friends but not in :frinds?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Ford</title>
		<link>http://www.aldenta.com/2006/11/10/has_many-through-self-referential-example/comment-page-1/#comment-4127</link>
		<dc:creator>John Ford</dc:creator>
		<pubDate>Fri, 18 May 2007 00:57:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.aldenta.com/2006/11/11/has_many-through-self-referential-example/#comment-4127</guid>
		<description>Nick, it should work fine since @user.friends will make an SQL call that says &quot;user_id = ?&quot; making sure only friends associated with that user_id are found.

If you&#039;ve befriended yourself then you might get back your own user object... which is your best friend... or something.</description>
		<content:encoded><![CDATA[<p>Nick, it should work fine since @user.friends will make an SQL call that says &#8220;user_id = ?&#8221; making sure only friends associated with that user_id are found.</p>
<p>If you&#8217;ve befriended yourself then you might get back your own user object&#8230; which is your best friend&#8230; or something.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
