drnic/composite_primary_keys — pull request #104 by TylerRick (2012-05-08 18:36:03+00:00)
Title: Setting a belongs_to association to nil raise an error (NoMethodError: undefined method `length' for nil:NilClass)

ActiveRecord will set this "attribute" to nil right here:

def replace_keys(record)
if record
owner[reflection.foreign_key] = record[reflection.association_primary_key(record.class)]
else
owner[reflection.foreign_key] = nil
end
end

so we need to allow nil as a valid value.