<?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"
	>
<channel>
	<title>Comments on: Has Many Through Association</title>
	<atom:link href="http://www.infused.org/2005/12/06/has-many-through-association/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.infused.org/2005/12/06/has-many-through-association/</link>
	<description></description>
	<pubDate>Fri,  4 Jul 2008 18:21:04 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Poli</title>
		<link>http://www.infused.org/2005/12/06/has-many-through-association/#comment-16455</link>
		<dc:creator>Poli</dc:creator>
		<pubDate>Wed, 26 Dec 2007 18:00:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.infused.org/?p=322#comment-16455</guid>
		<description>Hello, I want to know if that is good for my aplicattion, I have three tables in mysql;
the first is Person, the second is  Friend, and the third is persons_friends

These tables has :
has_and_belong_to_many for relationship

Then, I have a fourth table that is related with persons_friends; 
I don't know how to do a relationship between the fourth table and persons_friends

Poli</description>
		<content:encoded><![CDATA[<p>Hello, I want to know if that is good for my aplicattion, I have three tables in mysql;<br />
the first is Person, the second is  Friend, and the third is persons_friends</p>
<p>These tables has :<br />
has_and_belong_to_many for relationship</p>
<p>Then, I have a fourth table that is related with persons_friends;<br />
I don&#8217;t know how to do a relationship between the fourth table and persons_friends</p>
<p>Poli</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: flip&#8217;s &#187; has_and_belongs_to_many-Beziehung (habtm) mit zusÃ¤tzlichen Attributen</title>
		<link>http://www.infused.org/2005/12/06/has-many-through-association/#comment-15004</link>
		<dc:creator>flip&#8217;s &#187; has_and_belongs_to_many-Beziehung (habtm) mit zusÃ¤tzlichen Attributen</dc:creator>
		<pubDate>Sun, 19 Aug 2007 10:14:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.infused.org/?p=322#comment-15004</guid>
		<description>[...] Die habtm-Funktionalit&#228;t in Rails ist f&#252;r n:m-Beziehungen gedacht. Was aber, wenn jede dieser Beziehungen zus&#228;tzliche Attribute mit sich bringen soll? Beispiel: ein User soll Teil verschiedener Gruppen sein k&#246;nnen und einer Gruppe sollen mehrere User angeh&#246;ren k&#246;nnen. Um dies umzusetzen, ist die habtm-Beziehung perfekt. Nun soll aber zus&#228;tzlich jeder User einer Gruppe eine Rolle inne habe, z.B. User 1 hat in Gruppe 1 die Rolle &#8220;admin&#8221;, in Gruppe 2 &#8220;member&#8221; etc. Hierf&#252;r bietet sich sich eine &#8220;has_many through&#8221; an. Weiteres unter http://www.infused.org/2005/12/06/has-many-through-association/ [...]</description>
		<content:encoded><![CDATA[<p>[...] Die habtm-Funktionalit&#228;t in Rails ist f&#252;r n:m-Beziehungen gedacht. Was aber, wenn jede dieser Beziehungen zus&#228;tzliche Attribute mit sich bringen soll? Beispiel: ein User soll Teil verschiedener Gruppen sein k&#246;nnen und einer Gruppe sollen mehrere User angeh&#246;ren k&#246;nnen. Um dies umzusetzen, ist die habtm-Beziehung perfekt. Nun soll aber zus&#228;tzlich jeder User einer Gruppe eine Rolle inne habe, z.B. User 1 hat in Gruppe 1 die Rolle &#8220;admin&#8221;, in Gruppe 2 &#8220;member&#8221; etc. Hierf&#252;r bietet sich sich eine &#8220;has_many through&#8221; an. Weiteres unter <a href="http://www.infused.org/2005/12/06/has-many-through-association/" rel="nofollow">http://www.infused.org/2005/12/06/has-many-through-association/</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CindiDevBlog &#187; Blog Archive &#187; additional fields in habtm-relations</title>
		<link>http://www.infused.org/2005/12/06/has-many-through-association/#comment-7513</link>
		<dc:creator>CindiDevBlog &#187; Blog Archive &#187; additional fields in habtm-relations</dc:creator>
		<pubDate>Mon, 18 Sep 2006 15:16:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.infused.org/?p=322#comment-7513</guid>
		<description>[...] Links zum Thema:  rubyonrails.com::wiki::ThroughAssociations matthewman.net/&#8230;/activerecord-goes-through api.rubyonrails.org/&#8230;/ActiveRecord/&#8230;/ClassMethods wiki.rubyonrails.org/&#8230;/PolymorphicAssociations infused.org/&#8230;/has-many-through-association gmane.comp.lang.ruby.rails blog.hasmanythrough.com/&#8230;/associations blog.hasmanythrough.com/../many-to-many-dance-off wiki.rubyonrails.org/&#8230;/Beginner+Howto+on+has_many+through [...]</description>
		<content:encoded><![CDATA[<p>[...] Links zum Thema:  rubyonrails.com::wiki::ThroughAssociations matthewman.net/&#8230;/activerecord-goes-through api.rubyonrails.org/&#8230;/ActiveRecord/&#8230;/ClassMethods wiki.rubyonrails.org/&#8230;/PolymorphicAssociations infused.org/&#8230;/has-many-through-association gmane.comp.lang.ruby.rails blog.hasmanythrough.com/&#8230;/associations blog.hasmanythrough.com/../many-to-many-dance-off wiki.rubyonrails.org/&#8230;/Beginner+Howto+on+has_many+through [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike at SEOG.net</title>
		<link>http://www.infused.org/2005/12/06/has-many-through-association/#comment-7085</link>
		<dc:creator>Mike at SEOG.net</dc:creator>
		<pubDate>Fri, 21 Jul 2006 19:14:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.infused.org/?p=322#comment-7085</guid>
		<description>What is helpful about it is the additional aspects you can add when you flush out the model like that. You can say when a subscription was created, who created it, and so forth. By making the model of subscriptions it is easier to add functionality that is often wanted by marketing and business folks.  Although he was talking about cases where the subscription model wasn't defined, where it was simply a many to many relationship. Joining things with the has many :through and creating a new model allows one to stay "CRUD"-y and the benefits that comes along with that.</description>
		<content:encoded><![CDATA[<p>What is helpful about it is the additional aspects you can add when you flush out the model like that. You can say when a subscription was created, who created it, and so forth. By making the model of subscriptions it is easier to add functionality that is often wanted by marketing and business folks.  Although he was talking about cases where the subscription model wasn&#8217;t defined, where it was simply a many to many relationship. Joining things with the has many :through and creating a new model allows one to stay &#8220;CRUD&#8221;-y and the benefits that comes along with that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BeepHONK rumbles to life&#8230; at 72mach1.com</title>
		<link>http://www.infused.org/2005/12/06/has-many-through-association/#comment-5504</link>
		<dc:creator>BeepHONK rumbles to life&#8230; at 72mach1.com</dc:creator>
		<pubDate>Thu, 13 Apr 2006 02:52:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.infused.org/?p=322#comment-5504</guid>
		<description>[...] I&#8217;ve got most of the initial featureset roughed in. It&#8217;s even got some sprinklings of AJAX and DOM JavaScript effects. I&#8217;ve got a problem with the :through relationships that came about somewhere between the 1.0 and 1.1 release of Rails. Never fear though I&#8217;ll get it working soon enough. [...]</description>
		<content:encoded><![CDATA[<p>[...] I&#8217;ve got most of the initial featureset roughed in. It&#8217;s even got some sprinklings of AJAX and DOM JavaScript effects. I&#8217;ve got a problem with the :through relationships that came about somewhere between the 1.0 and 1.1 release of Rails. Never fear though I&#8217;ll get it working soon enough. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edoardo "Dado" Marcora</title>
		<link>http://www.infused.org/2005/12/06/has-many-through-association/#comment-5487</link>
		<dc:creator>Edoardo "Dado" Marcora</dc:creator>
		<pubDate>Tue, 14 Mar 2006 08:46:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.infused.org/?p=322#comment-5487</guid>
		<description>I also need it for a self-referential many-to-many relationship and I also can't get it to work.</description>
		<content:encoded><![CDATA[<p>I also need it for a self-referential many-to-many relationship and I also can&#8217;t get it to work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Randy Schmidt</title>
		<link>http://www.infused.org/2005/12/06/has-many-through-association/#comment-5471</link>
		<dc:creator>Randy Schmidt</dc:creator>
		<pubDate>Tue, 28 Feb 2006 05:17:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.infused.org/?p=322#comment-5471</guid>
		<description>I think I really need this for a site I'm working on, however, I need it for a self-referential many-to-many relationship and I have had no luck getting it to work. Does anybody know how I could make this work?</description>
		<content:encoded><![CDATA[<p>I think I really need this for a site I&#8217;m working on, however, I need it for a self-referential many-to-many relationship and I have had no luck getting it to work. Does anybody know how I could make this work?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Morris</title>
		<link>http://www.infused.org/2005/12/06/has-many-through-association/#comment-4516</link>
		<dc:creator>Peter Morris</dc:creator>
		<pubDate>Sat, 31 Dec 2005 08:30:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.infused.org/?p=322#comment-4516</guid>
		<description>Hmmm, the original code, before the "through" could be re-written like......

@users = User.find :all, :conditions =&#62; â€œname like â€˜k%â€™â€?
@users.each {&#124;u&#124; u.subscriptions.each{&#124;s&#124; s.mail(u.email,s.email_format)}}

you could even get rid of @users and have the .each hanging off of the find.

You COULD do sommat like....

@users = find ... blah blah ...
@users.collect{&#124;u&#124; u.subscriptions.collect{&#124;s&#124; [u, s]}}.each{&#124;t&#124; t[1].mail(t[0].email, t[1].email_format)}

But it would be a bad idea, as you would be building an in-memory array with as many rows as you have subscriptions whos subscribers name begins with 'k'.</description>
		<content:encoded><![CDATA[<p>Hmmm, the original code, before the &#8220;through&#8221; could be re-written like&#8230;&#8230;</p>
<p>@users = User.find :all, :conditions =&gt; â€œname like â€˜k%â€™â€?<br />
@users.each {|u| u.subscriptions.each{|s| s.mail(u.email,s.email_format)}}</p>
<p>you could even get rid of @users and have the .each hanging off of the find.</p>
<p>You COULD do sommat like&#8230;.</p>
<p>@users = find &#8230; blah blah &#8230;<br />
@users.collect{|u| u.subscriptions.collect{|s| [u, s]}}.each{|t| t[1].mail(t[0].email, t[1].email_format)}</p>
<p>But it would be a bad idea, as you would be building an in-memory array with as many rows as you have subscriptions whos subscribers name begins with &#8216;k&#8217;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon Harris</title>
		<link>http://www.infused.org/2005/12/06/has-many-through-association/#comment-4362</link>
		<dc:creator>Simon Harris</dc:creator>
		<pubDate>Sun, 25 Dec 2005 23:04:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.infused.org/?p=322#comment-4362</guid>
		<description>Excellent. I look forward to it.

Cheers,

Simon

P.S. Apologies for the unformatted code. It was late and I didn't notice the list of allowable tags below :)</description>
		<content:encoded><![CDATA[<p>Excellent. I look forward to it.</p>
<p>Cheers,</p>
<p>Simon</p>
<p>P.S. Apologies for the unformatted code. It was late and I didn&#8217;t notice the list of allowable tags below :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Admin</title>
		<link>http://www.infused.org/2005/12/06/has-many-through-association/#comment-4361</link>
		<dc:creator>Admin</dc:creator>
		<pubDate>Sun, 25 Dec 2005 22:38:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.infused.org/?p=322#comment-4361</guid>
		<description>Simon,  

You're right.  In my rather contrived example it would be better to use the following code:

&lt;code&gt;@users = User.find :all, :conditions =&#62; "name like 'k%'"
@users.each do &#124;u&#124;
&#160;&#160;u.newsletters.each do &#124;n&#124; 
&#160;&#160;&#160;&#160;n.mail(u.email,n.subscription.mail_format)
&#160;&#160;end
end&lt;/code&gt;

I am using the through associations in several places in one of my projects to good effect.  When I get some time, I'll post another entry that's based on some real-world usage.</description>
		<content:encoded><![CDATA[<p>Simon,  </p>
<p>You&#8217;re right.  In my rather contrived example it would be better to use the following code:</p>
<p><code>@users = User.find :all, :conditions =&gt; "name like 'k%'"<br />
@users.each do |u|<br />
&nbsp;&nbsp;u.newsletters.each do |n|<br />
&nbsp;&nbsp;&nbsp;&nbsp;n.mail(u.email,n.subscription.mail_format)<br />
&nbsp;&nbsp;end<br />
end</code></p>
<p>I am using the through associations in several places in one of my projects to good effect.  When I get some time, I&#8217;ll post another entry that&#8217;s based on some real-world usage.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
