<?xml version="1.0" encoding="UTF-8"?>
<posts>
  <post>
    <blog-id type="integer"></blog-id>
    <body>&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;</body>
    <body-raw>This year I have decided to try and read through the unread books on my bookshelves. I will be maintaining the list here.

1. [![Brave New World][amazonBNW-img]][amazonBNW]
2. [![The Catcher in the Rye][amazonCITR-img]][amazonCITR]
3. [![Longtitude][amazonLONG-img]][amazonLONG]
4. [![What I Talk About When I Talk About Running][amazonRUN-img]][amazonRUN]
5. [![The Algebraist][amazonALG-img]][amazonALG]
6. [![The Pragmatic Programmer][amazonPRAG-img]][amazonPRAG]
7. [![The Shadow Rising][amazonSHAD-img]][amazonSHAD]
8. [![The Alchemist][amazonALCH-img]][amazonALCH]
9. [![Walking on Glass][amazonWOG-img]][amazonWOG]
10. [![Anna Karenina][amazonAK-img]][amazonAK]



amazonBNW: 0099518473
amazonCITR: 014023750X
amazonLONG: 0007214227
amazonRUN: 0099526158
amazonALG: 1841492299
amazonPRAG: 020161622X
amazonSHAD: 185723121X
amazonALCH: 0722532938
amazonWOG: 0349101787
amazonAK: 0140449175</body-raw>
    <created-at type="datetime">2009-05-25T05:36:00-07:00</created-at>
    <id type="integer">379</id>
    <status type="integer">1</status>
    <title>Books Read in 2009</title>
    <updated-at type="datetime">2009-05-25T05:47:50-07:00</updated-at>
  </post>
  <post>
    <blog-id type="integer"></blog-id>
    <body>&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;</body>
    <body-raw>If you are using [Factory Girl](http://github.com/thoughtbot/factory_girl/tree/master), then you may be wondering how to define the factories for those `has_many :through` associations you have.

## Models

The example models we will use are:
	
    class BeeKeeper &lt; ActiveRecord::Base
      has_many :bees
      has_many :hives, :through =&gt; :bees
    end

    class Hive &lt; ActiveRecord::Base
      has_many :bees
      has_many :bee_keepers, :through =&gt; :bees
    end

    class Bee &lt; ActiveRecord::Base
      belongs_to :bee_keeper
      belongs_to :hive
    end

## Factories for Testing

So, to test these relationships you would define Factories.
Let's start by specifying the belongs_tos

    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

By creating a bee, it should also create a beekeeper and a hive.

## We're Done!

Actually, this is all you need to do for `has_many :through` - when you add hives to bee_keepers, they will automatically create the bees!

    context "Bee Keepers" do
      setup do
        @bee_keeper = Factory(:bee_keeper)
        @bee_keeper.hives &lt;&lt; Factory(:hive)
        @bee_keeper.hives &lt;&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

This will create:

* 1 bee keeper
* 2 bees
* 2 hives

Hope this helps some of you.</body-raw>
    <created-at type="datetime">2009-04-24T07:23:00-07:00</created-at>
    <id type="integer">378</id>
    <status type="integer">1</status>
    <title>Factory Girl and has_many :through</title>
    <updated-at type="datetime">2009-04-24T07:32:35-07:00</updated-at>
  </post>
  <post>
    <blog-id type="integer"></blog-id>
    <body>&lt;p&gt;I have just turned on mod_rails on Dreamhost. Let's see how it goes.&lt;/p&gt;</body>
    <body-raw>I have just turned on mod_rails on Dreamhost. Let's see how it goes.</body-raw>
    <created-at type="datetime">2008-05-21T12:30:00-07:00</created-at>
    <id type="integer">377</id>
    <status type="integer">1</status>
    <title>mod_rails on Dreamhost</title>
    <updated-at type="datetime">2008-05-21T12:31:53-07:00</updated-at>
  </post>
  <post>
    <blog-id type="integer"></blog-id>
    <body>&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;</body>
    <body-raw>My lack of posting here is because I have been spending time elsewhere. You can find me at the following hang outs:

- [Twitter](http://twitter.com/snowblink) - I tweet pretty much every day.
- [Flickr](http://flickr.com/snowblink) - I post photos here at least once a week, usually more.
- [Upcoming](http://upcoming.yahoo.com/user/50419/) - You can see what I'm up to or interested in going to.
- [Google Reader Shared](https://www.google.com/reader/shared/04916286328346643300) - funny or interesting stuff I find in my RSS feeds.
- [Delicious](http://del.icio.us/snowblink) - Any links which don't come from RSS feeds.
- [Github](http://github.com/snowblink) - It's where the cool kids keep their code these days.
- [Lighthouse](http://snowblink.lighthouseapp.com/) - Issue tracking, seeing use now because they now accommodate open source projects for free.
- [Dopplr](http://www.dopplr.com/traveller/snowblink) - Where am I?
- LinkedIn - Only vaguely using this. Just barely more useful than Facebook.
- Facebook - I removed my account over a year ago, due to the pointlessness of it. Don't try to contact me there.

</body-raw>
    <created-at type="datetime">2008-05-17T09:09:00-07:00</created-at>
    <id type="integer">376</id>
    <status type="integer">1</status>
    <title>Where to Find Me</title>
    <updated-at type="datetime">2008-05-17T09:10:22-07:00</updated-at>
  </post>
  <post>
    <blog-id type="integer"></blog-id>
    <body>&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;</body>
    <body-raw>Hayfever is back with our first stint of summer weather. 

In order to give us some warning, I have created a twitter bot which tweets daily based on information found at the [BBC website](http://bbc.co.uk/weather/pollen). It currently reports on London only.

- [pollen_london](http://twitter.com/pollen_london) - Twitter account
- [Github](http://github.com/snowblink/pollen-london/tree/master) - Source code is open source
- [Lighthouse](http://snowblink.lighthouseapp.com/projects/11315-pollen-london/) - Please report bugs</body-raw>
    <created-at type="datetime">2008-05-16T10:26:00-07:00</created-at>
    <id type="integer">375</id>
    <status type="integer">1</status>
    <title>Pollen London</title>
    <updated-at type="datetime">2008-05-16T10:38:32-07:00</updated-at>
  </post>
</posts>
