<?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: Rails has and belongs to many (habtm) demystified</title>
	<atom:link href="http://ramblings.gibberishcode.net/archives/rails-has-and-belongs-to-many-habtm-demystified/17/feed" rel="self" type="application/rss+xml" />
	<link>http://ramblings.gibberishcode.net/archives/rails-has-and-belongs-to-many-habtm-demystified/17</link>
	<description>about fetching, interpreting, and executing.</description>
	<lastBuildDate>Mon, 19 Dec 2011 19:23:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: has_and_belongs_to_many relationship not associating both ways - Programmers Goodies</title>
		<link>http://ramblings.gibberishcode.net/archives/rails-has-and-belongs-to-many-habtm-demystified/17/comment-page-1#comment-13308</link>
		<dc:creator>has_and_belongs_to_many relationship not associating both ways - Programmers Goodies</dc:creator>
		<pubDate>Sun, 21 Aug 2011 14:52:48 +0000</pubDate>
		<guid isPermaLink="false">http://ramblings.gibberishcode.net/?p=17#comment-13308</guid>
		<description>[...] Is the has_and_belongs_to_many present in both models? It sounds like it is not, whereas it should be: [...]</description>
		<content:encoded><![CDATA[<p>[...] Is the has_and_belongs_to_many present in both models? It sounds like it is not, whereas it should be: [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: marc_andre</title>
		<link>http://ramblings.gibberishcode.net/archives/rails-has-and-belongs-to-many-habtm-demystified/17/comment-page-1#comment-13294</link>
		<dc:creator>marc_andre</dc:creator>
		<pubDate>Thu, 03 Mar 2011 21:38:06 +0000</pubDate>
		<guid isPermaLink="false">http://ramblings.gibberishcode.net/?p=17#comment-13294</guid>
		<description>Nice post. I noticed you didn&#039;t label the checkboxes for the OS, you may want to edit your post to make the UI more user-friendly. See also &lt;a href=&quot;http://giraffesoft.ca/blog/2009/04/30/label-your-checkboxes-and-radio-buttons-to-ease-your-users-woes.html&quot; rel=&quot;nofollow&quot;&gt;http://giraffesoft.ca/blog/200...&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Nice post. I noticed you didn&#39;t label the checkboxes for the OS, you may want to edit your post to make the UI more user-friendly. See also <a href="http://giraffesoft.ca/blog/2009/04/30/label-your-checkboxes-and-radio-buttons-to-ease-your-users-woes.html" rel="nofollow"></a><a href="http://giraffesoft.ca/blog/200.." rel="nofollow">http://giraffesoft.ca/blog/200..</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Learning Ruby &#8211; Drop Down Lists in One to Many Relationships &#171; Tunaslut</title>
		<link>http://ramblings.gibberishcode.net/archives/rails-has-and-belongs-to-many-habtm-demystified/17/comment-page-1#comment-13260</link>
		<dc:creator>Learning Ruby &#8211; Drop Down Lists in One to Many Relationships &#171; Tunaslut</dc:creator>
		<pubDate>Wed, 12 May 2010 18:47:06 +0000</pubDate>
		<guid isPermaLink="false">http://ramblings.gibberishcode.net/?p=17#comment-13260</guid>
		<description>[...] here for some good reading on relationships in [...]</description>
		<content:encoded><![CDATA[<p>[...] here for some good reading on relationships in [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mike</title>
		<link>http://ramblings.gibberishcode.net/archives/rails-has-and-belongs-to-many-habtm-demystified/17/comment-page-1#comment-13234</link>
		<dc:creator>mike</dc:creator>
		<pubDate>Wed, 10 Mar 2010 02:20:33 +0000</pubDate>
		<guid isPermaLink="false">http://ramblings.gibberishcode.net/?p=17#comment-13234</guid>
		<description>Thank you very much for your effort in putting this info up.  I have a love/hate relationship with rails, and I do the exact same thing every time I do habtm in rails.  I have bookmarked this page for future reference...thanks again!  (deciphering rails&#039; convention with habtm when you have ModelThing and ModelStuff.  where do the underscores go and what/where gets pluralized? NARGH!)</description>
		<content:encoded><![CDATA[<p>Thank you very much for your effort in putting this info up.  I have a love/hate relationship with rails, and I do the exact same thing every time I do habtm in rails.  I have bookmarked this page for future reference&#8230;thanks again!  (deciphering rails&#39; convention with habtm when you have ModelThing and ModelStuff.  where do the underscores go and what/where gets pluralized? NARGH!)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://ramblings.gibberishcode.net/archives/rails-has-and-belongs-to-many-habtm-demystified/17/comment-page-1#comment-6816</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Fri, 27 Mar 2009 20:00:23 +0000</pubDate>
		<guid isPermaLink="false">http://ramblings.gibberishcode.net/?p=17#comment-6816</guid>
		<description>@Clint:  I am no expert, either.  I have never used the &quot;rescue []&quot; myself, so I&#039;ll have to crack open and irb session and explore some more on this one.  Thanks for the tip!  as for the check for an item existing in a list, I hear that detect is faster than include, but I have not verified.  An example:

&lt;pre&gt;
&lt;%= check_box_tag(&quot;browser[os_list][#{os.id}]&quot;, &quot;1&quot;, 
             @browser.oses.detect{&#124;d&#124; d == os}) %&gt;
&lt;/pre&gt;

You probably know this, but one thing to watch out for when assigning new associations is to remember that the user can opt to remove existing assocations, so that&#039;s why I do the delete all.  I used to write a lot of code to detect and add/remove but found the code getting far more complicated than if I just simply cleared the list and add the chosen associations afresh.</description>
		<content:encoded><![CDATA[<p>@Clint:  I am no expert, either.  I have never used the &#8220;rescue []&#8221; myself, so I&#8217;ll have to crack open and irb session and explore some more on this one.  Thanks for the tip!  as for the check for an item existing in a list, I hear that detect is faster than include, but I have not verified.  An example:</p>
<pre>
< %= check_box_tag("browser[os_list][#{os.id}]", "1",
             @browser.oses.detect{|d| d == os}) %>
</pre>
<p>You probably know this, but one thing to watch out for when assigning new associations is to remember that the user can opt to remove existing assocations, so that&#8217;s why I do the delete all.  I used to write a lot of code to detect and add/remove but found the code getting far more complicated than if I just simply cleared the list and add the chosen associations afresh.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Clint</title>
		<link>http://ramblings.gibberishcode.net/archives/rails-has-and-belongs-to-many-habtm-demystified/17/comment-page-1#comment-6800</link>
		<dc:creator>Clint</dc:creator>
		<pubDate>Thu, 26 Mar 2009 17:52:52 +0000</pubDate>
		<guid isPermaLink="false">http://ramblings.gibberishcode.net/?p=17#comment-6800</guid>
		<description>I&#039;m not an expert, but wouldn&#039;t this do the same thing?

def update_oses
  oses.delete_all
  self.oses &lt;&lt; Os.find(os_list.keys) rescue []
end

I often do this to add new associates to users for instance but have wondered if it was the most efficient.

user.browsers &lt;&lt; browser unless user.browsers.include?(browser)</description>
		<content:encoded><![CDATA[<p>I&#8217;m not an expert, but wouldn&#8217;t this do the same thing?</p>
<p>def update_oses<br />
  oses.delete_all<br />
  self.oses &lt;&lt; Os.find(os_list.keys) rescue []<br />
end</p>
<p>I often do this to add new associates to users for instance but have wondered if it was the most efficient.</p>
<p>user.browsers &lt;&lt; browser unless user.browsers.include?(browser)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

