<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -32,7 +32,7 @@ module Machinist
       attributes = {}
       lathe.assigned_attributes.each_pair do |attribute, value|
         association = lathe.object.class.reflect_on_association(attribute)
-        if association &amp;&amp; association.macro == :belongs_to
+        if association &amp;&amp; association.macro == :belongs_to &amp;&amp; !value.nil?
           attributes[association.primary_key_name.to_sym] = value.id
         else
           attributes[attribute] = value</diff>
      <filename>lib/machinist/active_record.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,6 @@
 require File.dirname(__FILE__) + '/spec_helper'
 require 'machinist/active_record'
+require 'active_support/whiny_nil'
 
 module MachinistActiveRecordSpecs
   
@@ -131,6 +132,16 @@ module MachinistActiveRecordSpecs
         comment[:post].should be_nil
         comment[:post_id].should_not be_nil
       end
+
+      describe &quot;on a belongs_to association&quot; do
+        it &quot;should allow explicitly setting the association to nil&quot; do
+          Comment.blueprint { post }
+          Comment.blueprint(:no_post) { post { nil } }
+          lambda {
+            @comment = Comment.plan(:no_post)
+          }.should_not raise_error
+        end
+      end
   
       describe &quot;on a has_many association&quot; do
         before do</diff>
      <filename>spec/active_record_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>abddd6b36b2f2d764d27660b0c02c62eb7e0aa65</id>
    </parent>
  </parents>
  <author>
    <name>Kevin Bullock</name>
    <email>kbullock@ringworld.org</email>
  </author>
  <url>http://github.com/notahat/machinist/commit/a98739d88e7fb97ab5afdf5ca83004dabc0ce3cb</url>
  <id>a98739d88e7fb97ab5afdf5ca83004dabc0ce3cb</id>
  <committed-date>2009-10-31T22:36:56-07:00</committed-date>
  <authored-date>2009-10-15T08:19:59-07:00</authored-date>
  <message>allow setting belongs_to id to nil, even if nil is whiny</message>
  <tree>04524f1fc919577e482c8f6f179724d163022ed7</tree>
  <committer>
    <name>Pete Yandell</name>
    <email>pete@notahat.com</email>
  </committer>
</commit>
