<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
  <channel>
    <title>Snowblink</title>
    <link>http://snowblink.co.uk/</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/snowblink" /><feedburner:info uri="snowblink" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
      <title>Books Read in 2009</title>
      <description>&lt;p&gt;This year I have decided to try and read through the unread books on my bookshelves. I will be maintaining the list here.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="http://www.amazon.co.uk/Brave-New-World-Aldous-Huxley/dp/0099518473%3FSubscriptionId%3D180CCZQDRSAWM30FTCG2%26tag%3Dsnowblink03%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0099518473"&gt;&lt;img src="http://ecx.images-amazon.com/images/I/41TdW-C0v2L._SL160_.jpg" alt="Brave New World"/&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.amazon.co.uk/Catcher-Rye-J-D-Salinger/dp/014023750X%3FSubscriptionId%3D180CCZQDRSAWM30FTCG2%26tag%3Dsnowblink03%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D014023750X"&gt;&lt;img src="http://ecx.images-amazon.com/images/I/31aFcAsxfDL._SL160_.jpg" alt="The Catcher in the Rye"/&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.amazon.co.uk/Longitude-Dava-Sobel/dp/0007214227%3FSubscriptionId%3D180CCZQDRSAWM30FTCG2%26tag%3Dsnowblink03%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0007214227"&gt;&lt;img src="http://ecx.images-amazon.com/images/I/51TMQDVSVRL._SL160_.jpg" alt="Longtitude"/&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.amazon.co.uk/What-Talk-About-When-Running/dp/0099526158%3FSubscriptionId%3D180CCZQDRSAWM30FTCG2%26tag%3Dsnowblink03%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0099526158"&gt;&lt;img src="http://ecx.images-amazon.com/images/I/41cVr1DsVhL._SL160_.jpg" alt="What I Talk About When I Talk About Running"/&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.amazon.co.uk/Algebraist-Iain-M-Banks/dp/1841492299%3FSubscriptionId%3D180CCZQDRSAWM30FTCG2%26tag%3Dsnowblink03%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D1841492299"&gt;&lt;img src="http://ecx.images-amazon.com/images/I/512JSQEWV7L._SL160_.jpg" alt="The Algebraist"/&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.amazon.co.uk/Pragmatic-Programmer-Andrew-Hunt/dp/020161622X%3FSubscriptionId%3D180CCZQDRSAWM30FTCG2%26tag%3Dsnowblink03%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D020161622X"&gt;&lt;img src="http://ecx.images-amazon.com/images/I/41hImUq3RKL._SL160_.jpg" alt="The Pragmatic Programmer"/&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.amazon.co.uk/Shadow-Rising-Wheel-Time/dp/185723121X%3FSubscriptionId%3D180CCZQDRSAWM30FTCG2%26tag%3Dsnowblink03%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D185723121X"&gt;&lt;img src="http://ecx.images-amazon.com/images/I/41F9SC8XEQL._SL160_.jpg" alt="The Shadow Rising"/&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.amazon.co.uk/Alchemist-Fable-About-Following-Dream/dp/0722532938%3FSubscriptionId%3D180CCZQDRSAWM30FTCG2%26tag%3Dsnowblink03%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0722532938"&gt;&lt;img src="http://ecx.images-amazon.com/images/I/51J48CZ3ZWL._SL160_.jpg" alt="The Alchemist"/&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.amazon.co.uk/Walking-Glass-Iain-Banks/dp/0349101787%3FSubscriptionId%3D180CCZQDRSAWM30FTCG2%26tag%3Dsnowblink03%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0349101787"&gt;&lt;img src="http://ecx.images-amazon.com/images/I/415aDPKOUeL._SL160_.jpg" alt="Walking on Glass"/&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.amazon.co.uk/Anna-Karenina-Penguin-Classics-Tolstoy/dp/0140449175%3FSubscriptionId%3D180CCZQDRSAWM30FTCG2%26tag%3Dsnowblink03%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0140449175"&gt;&lt;img src="http://ecx.images-amazon.com/images/I/41GZL6bG8zL._SL160_.jpg" alt="Anna Karenina"/&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;</description>
      <pubDate>Mon, 25 May 2009 05:47:50 -0700</pubDate>
      <guid isPermaLink="false">http://snowblink.co.uk/posts/379</guid>
      <link>http://feedproxy.google.com/~r/snowblink/~3/w6drrmmduNw/379</link>
    <feedburner:origLink>http://snowblink.co.uk/posts/379</feedburner:origLink></item>
    <item>
      <title>Factory Girl and has_many :through</title>
      <description>&lt;p&gt;If you are using &lt;a href="http://github.com/thoughtbot/factory_girl/tree/master"&gt;Factory Girl&lt;/a&gt;, then you may be wondering how to define the factories for those &lt;code&gt;has_many :through&lt;/code&gt; associations you have.&lt;/p&gt;

&lt;h2&gt;Models&lt;/h2&gt;

&lt;p&gt;The example models we will use are:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class BeeKeeper &amp;lt; ActiveRecord::Base
  has_many :bees
  has_many :hives, :through =&amp;gt; :bees
end

class Hive &amp;lt; ActiveRecord::Base
  has_many :bees
  has_many :bee_keepers, :through =&amp;gt; :bees
end

class Bee &amp;lt; ActiveRecord::Base
  belongs_to :bee_keeper
  belongs_to :hive
end
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Factories for Testing&lt;/h2&gt;

&lt;p&gt;So, to test these relationships you would define Factories.
Let's start by specifying the belongs_tos&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Factory.define :bee do |b|
  b.bee_keeper {|a| a.association(:bee_keeper)}
  b.hive {|a| a.association(:hive)}
end

Factory.define :bee_keeper do |bk|
end

Factory.define :hive do |h|
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;By creating a bee, it should also create a beekeeper and a hive.&lt;/p&gt;

&lt;h2&gt;We're Done!&lt;/h2&gt;

&lt;p&gt;Actually, this is all you need to do for &lt;code&gt;has_many :through&lt;/code&gt; - when you add hives to bee_keepers, they will automatically create the bees!&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;context "Bee Keepers" do
  setup do
    @bee_keeper = Factory(:bee_keeper)
    @bee_keeper.hives &amp;lt;&amp;lt; Factory(:hive)
    @bee_keeper.hives &amp;lt;&amp;lt; Factory(:hive)
  end

  should "have 2 hives" do
    assert_equal 2, @bee_keeper.hives.length
  end

  should "have 2 bees" do
    assert_equal 2, @bee_keeper.bees.length
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will create:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1 bee keeper&lt;/li&gt;
&lt;li&gt;2 bees&lt;/li&gt;
&lt;li&gt;2 hives&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hope this helps some of you.&lt;/p&gt;</description>
      <pubDate>Fri, 24 Apr 2009 07:32:35 -0700</pubDate>
      <guid isPermaLink="false">http://snowblink.co.uk/posts/378</guid>
      <link>http://feedproxy.google.com/~r/snowblink/~3/lwwwIWirNtc/378</link>
    <feedburner:origLink>http://snowblink.co.uk/posts/378</feedburner:origLink></item>
    <item>
      <title>mod_rails on Dreamhost</title>
      <description>&lt;p&gt;I have just turned on mod_rails on Dreamhost. Let's see how it goes.&lt;/p&gt;</description>
      <pubDate>Wed, 21 May 2008 12:31:53 -0700</pubDate>
      <guid isPermaLink="false">http://snowblink.co.uk/posts/377</guid>
      <link>http://feedproxy.google.com/~r/snowblink/~3/TryeAoSXMeE/377</link>
    <feedburner:origLink>http://snowblink.co.uk/posts/377</feedburner:origLink></item>
    <item>
      <title>Where to Find Me</title>
      <description>&lt;p&gt;My lack of posting here is because I have been spending time elsewhere. You can find me at the following hang outs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://twitter.com/snowblink"&gt;Twitter&lt;/a&gt; - I tweet pretty much every day.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://flickr.com/snowblink"&gt;Flickr&lt;/a&gt; - I post photos here at least once a week, usually more.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://upcoming.yahoo.com/user/50419/"&gt;Upcoming&lt;/a&gt; - You can see what I'm up to or interested in going to.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.google.com/reader/shared/04916286328346643300"&gt;Google Reader Shared&lt;/a&gt; - funny or interesting stuff I find in my RSS feeds.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://del.icio.us/snowblink"&gt;Delicious&lt;/a&gt; - Any links which don't come from RSS feeds.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://github.com/snowblink"&gt;Github&lt;/a&gt; - It's where the cool kids keep their code these days.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://snowblink.lighthouseapp.com/"&gt;Lighthouse&lt;/a&gt; - Issue tracking, seeing use now because they now accommodate open source projects for free.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.dopplr.com/traveller/snowblink"&gt;Dopplr&lt;/a&gt; - Where am I?&lt;/li&gt;
&lt;li&gt;LinkedIn - Only vaguely using this. Just barely more useful than Facebook.&lt;/li&gt;
&lt;li&gt;Facebook - I removed my account over a year ago, due to the pointlessness of it. Don't try to contact me there.&lt;/li&gt;
&lt;/ul&gt;</description>
      <pubDate>Sat, 17 May 2008 09:10:22 -0700</pubDate>
      <guid isPermaLink="false">http://snowblink.co.uk/posts/376</guid>
      <link>http://feedproxy.google.com/~r/snowblink/~3/OK4lIsHmYPA/376</link>
    <feedburner:origLink>http://snowblink.co.uk/posts/376</feedburner:origLink></item>
    <item>
      <title>Pollen London</title>
      <description>&lt;p&gt;Hayfever is back with our first stint of summer weather. &lt;/p&gt;

&lt;p&gt;In order to give us some warning, I have created a twitter bot which tweets daily based on information found at the &lt;a href="http://bbc.co.uk/weather/pollen"&gt;BBC website&lt;/a&gt;. It currently reports on London only.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://twitter.com/pollen_london"&gt;pollen_london&lt;/a&gt; - Twitter account&lt;/li&gt;
&lt;li&gt;&lt;a href="http://github.com/snowblink/pollen-london/tree/master"&gt;Github&lt;/a&gt; - Source code is open source&lt;/li&gt;
&lt;li&gt;&lt;a href="http://snowblink.lighthouseapp.com/projects/11315-pollen-london/"&gt;Lighthouse&lt;/a&gt; - Please report bugs&lt;/li&gt;
&lt;/ul&gt;</description>
      <pubDate>Fri, 16 May 2008 10:38:32 -0700</pubDate>
      <guid isPermaLink="false">http://snowblink.co.uk/posts/375</guid>
      <link>http://feedproxy.google.com/~r/snowblink/~3/CoufzrMLg78/375</link>
    <feedburner:origLink>http://snowblink.co.uk/posts/375</feedburner:origLink></item>
  </channel>
</rss>
