<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -30,7 +30,7 @@ module CouchRest
     # Gets a reference to the top level extended
     # document that a model is saved inside of
     def base_doc
-      raise &quot;Cannot call base_doc on a model that is not yet casted by a document&quot; unless @casted_by
+      return nil unless @casted_by
       @casted_by.base_doc
     end
     </diff>
      <filename>lib/couchrest/more/casted_model.rb</filename>
    </modified>
    <modified>
      <diff>@@ -28,6 +28,7 @@ CouchRest::CastedModel.class_eval do
   # The to_param method is needed for rails to generate resourceful routes.
   # In your controller, remember that it's actually the id of the document.
   def id
+    return nil if base_doc.nil?
     base_doc.id
   end
   alias_method :to_param, :id</diff>
      <filename>lib/couchrest/support/rails.rb</filename>
    </modified>
    <modified>
      <diff>@@ -326,6 +326,11 @@ describe CouchRest::CastedModel do
       @toy1.base_doc.title = 'Tom Foolery'
       @course.title.should == 'Tom Foolery'
     end
+    
+    it &quot;should return nil if not yet casted&quot; do
+      person = Person.new
+      person.base_doc.should == nil
+    end
   end
   
   describe &quot;calling base_doc.save from a nested casted model&quot; do</diff>
      <filename>spec/couchrest/more/casted_model_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>027dd9a3ee1eb67499bf7a6643109ae283999e37</id>
    </parent>
  </parents>
  <author>
    <name>Peter Gumeson</name>
    <email>gumeson@gmail.com</email>
  </author>
  <url>http://github.com/wildchild/couchrest/commit/91cd1d9c7b7b8a14e517d1045c918a35185e0e89</url>
  <id>91cd1d9c7b7b8a14e517d1045c918a35185e0e89</id>
  <committed-date>2009-05-30T23:20:39-07:00</committed-date>
  <authored-date>2009-05-30T23:20:39-07:00</authored-date>
  <message>base_doc should be nil for unassociated casted models</message>
  <tree>9d581446ed65e04d1ad17d75f9106c5671704a93</tree>
  <committer>
    <name>Peter Gumeson</name>
    <email>gumeson@gmail.com</email>
  </committer>
</commit>
