This repository has been archived by the owner. It is now read-only.

Creating instances of a STI model with unloadable :type should error? #203

Open
kanzure opened this Issue May 30, 2012 · 0 comments

Comments

Projects
None yet
1 participant
@kanzure

kanzure commented May 30, 2012

Model.create should error when you pass in :type => "SomeOtherClass". For example, SomeOtherClass is a non-DM model. When later trying to load this particular instance from the db, there will be an error about "undefined method key for SomeOtherClass:Class". However, the error should probably occur during creation/saving?

class Model
  include DataMapper::Resource
  property :type, Discriminator
end

Suppose that someone is intending to use strings here for classes that don't exist. In this case, it would be better to use a string property to represent that. But if you're using Discriminator, you probably intend to reload the instance at some point.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.