
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
-
Sindre Aarsaether May 25th, 2008 @ 08:51 AM
- Assigned user changed from Sam Smoot to Sindre Aarsaether
-
Sindre Aarsaether May 25th, 2008 @ 09:27 AM
- State changed from new to hold
As far as I can see, this only happens with Animal / Zebra names. This has to something to do with other Animal classes in specs.
I've made a spec with other classnames that do pass.
If you can make an isolated spec that fails as above, please attach to this ticket, and I'll reopen it :-)
Spec can be found here
-
Piotr Solnica (solnic) May 28th, 2008 @ 03:15 PM
Hey, after pulling latest DO this bug is gone...but BTW, I was able to reproduce it only in a merb application...very weird stuff!
-
Sindre Aarsaether May 25th, 2008 @ 02:18 PM
- State changed from hold to invalid
-
Bernerd Schaefer June 10th, 2008 @ 11:15 AM
- no changes were found...
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.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »