#302 invalid
Piotr Solnica (solnic)

DataMapper::Collection#load gets broken when using STI

Reported by Piotr Solnica (solnic) | May 22nd, 2008 @ 10:36 AM

Lets say we have two very basic models:

class Animal
  include DataMapper::Resource
  
  property :id, Integer, :serial => true
  property :type, Discriminator
  property :name, String
  
end

class Zebra < Animal; end

Now we can create a zebra:

irb(main):009:0> Zebra.create :name => 'Marty'

=> #

Now we want to find it:

irb(main):010:0> Zebra.first :name => 'Marty'

NoMethodError: undefined method `allocate' for Zebra

A simple fix would be to use DataMapper::Inflection.constantize in DataMapper::Collection#load method, but I've got a feeling this would be more like a workaround then a real fix.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Pages