title: Rails 2.3.4: How to filter models sharing same tables based on their own type?
body: <p>Consider the following example code:</p>
  
  <pre><code>def Product &lt; ActiveRecord::Base
  end
  
  def Book &lt; Product
  end
  </code></pre>
  
  <p>(I gave up finding a name for this kind of relationship.  I thought Book is a "child model" and Product is the "parent," but that is incorrect.  For example, a Comment model object linked to another Comment model object is what would be a "child-parent" relationship.  If you have a better way to describe the relationship of the models in my code above, you're welcome to write it down here.  Either way, this is not really why I'm here.)</p>
  
  <p>Of course, with the code above, the Book model will share the same database table than Product, "products."  The model type will be saved as a string in the table's "type" column.  So, calling Product.create will insert a row in the table with the type value set to "Product" and using with Book.create will do the same but with the value of "Book."</p>
  
  <p>What puzzles me, however, is calling Book.last will return the last row with the type "Book," as I expect it, but Product.last will return the last row no matter what type, including "Product" and "Book," even though I wish to only get the last "Product."</p>
  
  <p>I tried defined a default_scope in Product which I override in my Book, but that causes more problems than it solves, and messed up my named scopes in Product which are inherited by Book.</p>
  
  <p>Is there a way to make Product.last return the last object of type "Product" and avoid any objects of type "Book"?</p>
  
  <p>Thanks in advance for your answers.</p>