So I'm coming back to DM after some hiatus. I'm looking at an AR
schema where STI relies on the magic "type" column to figure out what
the proposed class for a given row is. Here is some code:

class Collection
 include DataMapper::Resource
 property :id,         Serial
 property :name,       String
 property :type,       Class
 has n, :collection_items
 has n, :items, :through => :collection_items

 belongs_to :user
end

class Cart < Collection
 include DataMapper::Resource
 property :id, Serial
 property :total_cache, Integer
 property :item_count_cache, BigDecimal
end

Cart.all.each do |cart|
 puts "cart #{cart.id} is a #{cart.class} and has a total quantity of
#{cart.total_cache} and belongs to #{cart.user.name}"
end

The loop that iterates Carts gives me all Collections instead of only
those of type Cart. Am I misunderstanding how this is to work. If I
misunderstand it, how would this work with legacy database schema that
rely on a "type" column for disambiguation?

Thanks, and great work since the 0.3ish verisons.

Steve
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to