<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,7 +1,17 @@
 class Postie &lt; ActiveRecord::Base
   def Postie.find_by_pretty_id(pretty_id)
-    Postie.all.detect do |postie|
-      postie.name.downcase.gsub(/\W/, '') == pretty_id
+    postie = Postie.all.detect do |postie|
+      postie.pretty_id == pretty_id
     end
+    raise ActiveRecord::RecordNotFound unless postie
+    postie
+  end
+  
+  def pretty_id
+    self.name.downcase.gsub(/\W/, '')
+  end
+  
+  def to_param
+    self.pretty_id
   end
 end</diff>
      <filename>app/models/postie.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,5 +19,21 @@ describe Postie do
       
       Postie.find_by_pretty_id('mypostie').should == postie
     end
+    it &quot;should raise an error when no name matches&quot; do
+      postie = Postie.new(:name =&gt; 'My Postie')
+      postie.save!
+      
+      lambda{Postie.find_by_pretty_id('dontexist')}.should raise_error(ActiveRecord::RecordNotFound)
+    end
+  end
+  
+  it &quot;should know its pretty_id&quot; do
+    postie = Postie.new(:name =&gt; 'My Postie')
+    postie.pretty_id.should == 'mypostie'
+  end
+  
+  it &quot;should use its pretty_id for params&quot; do
+    postie = Postie.new(:name =&gt; 'My Postie')
+    postie.to_param.should == postie.pretty_id
   end
 end</diff>
      <filename>spec/models/postie_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>4dc282e558887f38b0337af1fcd22ba65a80db40</id>
    </parent>
  </parents>
  <author>
    <name>Paul Cortens</name>
    <email>paul@thoughtless.ca</email>
  </author>
  <url>http://github.com/thoughtless/cuc_demo/commit/679529424b0edce220e1f0c14d482bac5dcad59e</url>
  <id>679529424b0edce220e1f0c14d482bac5dcad59e</id>
  <committed-date>2008-11-24T13:17:26-08:00</committed-date>
  <authored-date>2008-11-24T13:17:26-08:00</authored-date>
  <message>have Postie#to_param use pretty_id</message>
  <tree>06c40f6a6e4d7e17f8cb2691de0f39ae7f37caeb</tree>
  <committer>
    <name>Paul Cortens</name>
    <email>paul@thoughtless.ca</email>
  </committer>
</commit>
