<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Factory Girl and has_many / has_many :through associations</title>
	<atom:link href="http://ditoinfo.wordpress.com/2008/11/19/factory-girl-and-has_many-has_many-through-associations/feed/" rel="self" type="application/rss+xml" />
	<link>http://ditoinfo.wordpress.com/2008/11/19/factory-girl-and-has_many-has_many-through-associations/</link>
	<description>talking about programming and computer stuff</description>
	<lastBuildDate>Tue, 20 Oct 2009 06:51:45 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Umuro</title>
		<link>http://ditoinfo.wordpress.com/2008/11/19/factory-girl-and-has_many-has_many-through-associations/#comment-189</link>
		<dc:creator>Umuro</dc:creator>
		<pubDate>Thu, 25 Jun 2009 15:21:00 +0000</pubDate>
		<guid isPermaLink="false">http://ditoinfo.wordpress.com/?p=85#comment-189</guid>
		<description>You are trying to write complicated factories? Maybe you need to add
helper methods to your factories to keep it clean. Here is how:
http://conceptspace.wikidot.com/blog:39

This allows you to define complicated belongs_to and has_many
scenarios neatly. For example: 

Factory.define :child do &#124;f&#124;

    class &lt;&lt; f
        #do whatever you can do in a normal class definition
        def default_parent
            @default_parent &#124;&#124;= Factory(:parent)
        end
    end

    f.sequence(:name) {&#124;n&#124; &quot;Child#{n}&quot;}
    f.parent_id { f.default_parent.id }
end</description>
		<content:encoded><![CDATA[<p>You are trying to write complicated factories? Maybe you need to add<br />
helper methods to your factories to keep it clean. Here is how:<br />
<a href="http://conceptspace.wikidot.com/blog:39" rel="nofollow">http://conceptspace.wikidot.com/blog:39</a></p>
<p>This allows you to define complicated belongs_to and has_many<br />
scenarios neatly. For example: </p>
<p>Factory.define :child do |f|</p>
<p>    class &lt;&lt; f<br />
        #do whatever you can do in a normal class definition<br />
        def default_parent<br />
            @default_parent ||= Factory(:parent)<br />
        end<br />
    end</p>
<p>    f.sequence(:name) {|n| &quot;Child#{n}&quot;}<br />
    f.parent_id { f.default_parent.id }<br />
end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William T</title>
		<link>http://ditoinfo.wordpress.com/2008/11/19/factory-girl-and-has_many-has_many-through-associations/#comment-185</link>
		<dc:creator>William T</dc:creator>
		<pubDate>Thu, 04 Jun 2009 03:36:54 +0000</pubDate>
		<guid isPermaLink="false">http://ditoinfo.wordpress.com/?p=85#comment-185</guid>
		<description>Nice tip. I respect you.</description>
		<content:encoded><![CDATA[<p>Nice tip. I respect you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Umur</title>
		<link>http://ditoinfo.wordpress.com/2008/11/19/factory-girl-and-has_many-has_many-through-associations/#comment-177</link>
		<dc:creator>Umur</dc:creator>
		<pubDate>Tue, 17 Mar 2009 11:17:24 +0000</pubDate>
		<guid isPermaLink="false">http://ditoinfo.wordpress.com/?p=85#comment-177</guid>
		<description>I simply tried the suggestion making
class User
   has_many :posts
class Post
   belongs_to :user

In the code above all groups end up with “user_id = nil”. Actually the factory creates the posts and the users. And the result is many unrelated posts and users. 

Can we consider it a bug or missing feature of factory girl?
The one to many definition does not work:
user.groups {&#124;groups&#124; [groups.association(:group)]}</description>
		<content:encoded><![CDATA[<p>I simply tried the suggestion making<br />
class User<br />
   has_many :posts<br />
class Post<br />
   belongs_to :user</p>
<p>In the code above all groups end up with “user_id = nil”. Actually the factory creates the posts and the users. And the result is many unrelated posts and users. </p>
<p>Can we consider it a bug or missing feature of factory girl?<br />
The one to many definition does not work:<br />
user.groups {|groups| [groups.association(:group)]}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dante regis</title>
		<link>http://ditoinfo.wordpress.com/2008/11/19/factory-girl-and-has_many-has_many-through-associations/#comment-176</link>
		<dc:creator>dante regis</dc:creator>
		<pubDate>Mon, 16 Mar 2009 23:57:00 +0000</pubDate>
		<guid isPermaLink="false">http://ditoinfo.wordpress.com/?p=85#comment-176</guid>
		<description>I&#039;m sure you couldn&#039;t, and that&#039;s not your fault. It&#039;s not there. I found it on a blog, but since I posted a few days after reading it, I could not remember the source, for what I am sorry.</description>
		<content:encoded><![CDATA[<p>I&#8217;m sure you couldn&#8217;t, and that&#8217;s not your fault. It&#8217;s not there. I found it on a blog, but since I posted a few days after reading it, I could not remember the source, for what I am sorry.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dante regis</title>
		<link>http://ditoinfo.wordpress.com/2008/11/19/factory-girl-and-has_many-has_many-through-associations/#comment-175</link>
		<dc:creator>dante regis</dc:creator>
		<pubDate>Mon, 16 Mar 2009 23:53:39 +0000</pubDate>
		<guid isPermaLink="false">http://ditoinfo.wordpress.com/?p=85#comment-175</guid>
		<description>can you tell us how your relationships are defined in the models so we can help you better?</description>
		<content:encoded><![CDATA[<p>can you tell us how your relationships are defined in the models so we can help you better?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Umur</title>
		<link>http://ditoinfo.wordpress.com/2008/11/19/factory-girl-and-has_many-has_many-through-associations/#comment-174</link>
		<dc:creator>Umur</dc:creator>
		<pubDate>Mon, 16 Mar 2009 02:23:37 +0000</pubDate>
		<guid isPermaLink="false">http://ditoinfo.wordpress.com/?p=85#comment-174</guid>
		<description>I try your suggestion but...
All groups end up with &quot;user_id = nil&quot;
Using factory_girl 1.2.0</description>
		<content:encoded><![CDATA[<p>I try your suggestion but&#8230;<br />
All groups end up with &#8220;user_id = nil&#8221;<br />
Using factory_girl 1.2.0</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andy white</title>
		<link>http://ditoinfo.wordpress.com/2008/11/19/factory-girl-and-has_many-has_many-through-associations/#comment-172</link>
		<dc:creator>andy white</dc:creator>
		<pubDate>Wed, 11 Feb 2009 15:16:48 +0000</pubDate>
		<guid isPermaLink="false">http://ditoinfo.wordpress.com/?p=85#comment-172</guid>
		<description>If it wasn&#039;t for excellent people like you - who find an answer to an annoying problem like this and then publish it to the world - people like me would spend hours hitting our heads against a brick wall. I salute you!

Just started using Factory Girl and it looks really useful but, unless I&#039;m being thick, I couldn&#039;t find this in the rdoc.</description>
		<content:encoded><![CDATA[<p>If it wasn&#8217;t for excellent people like you &#8211; who find an answer to an annoying problem like this and then publish it to the world &#8211; people like me would spend hours hitting our heads against a brick wall. I salute you!</p>
<p>Just started using Factory Girl and it looks really useful but, unless I&#8217;m being thick, I couldn&#8217;t find this in the rdoc.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
